Skip to content

Allow clearing story author on edit form#1544

Open
maebeale wants to merge 1 commit into
mainfrom
maebeale/charlotte
Open

Allow clearing story author on edit form#1544
maebeale wants to merge 1 commit into
mainfrom
maebeale/charlotte

Conversation

@maebeale

@maebeale maebeale commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #1517

What is the goal of this PR and why is this important?

  • On an existing (unpublished) story, the Story author field could not be cleared back to the "Select an author" placeholder — the deselect behavior only worked on the new-story form.
  • This was a stakeholder-reported bug; editors need to be able to unset the author and re-choose.

How did you approach the change?

  • The author select used simple_form's prompt: option, which only renders the placeholder <option> when no value is selected. On an existing story the author is already set, so the blank option was never rendered and there was nothing to select to clear the field.
  • Switched prompt: "Select an author" to include_blank: "Select an author", which always renders the blank option. This matches how workshop_id and organization_id already behave on the same form, and leaves the new-story form unchanged.
  • The existing select-placeholder styling and onchange handler already react to an empty value, so clearing now correctly re-applies the gray placeholder style.

Testing

  • Added a view spec asserting the edit form renders a blank option for story[created_by_id] (red before the fix, green after).
  • spec/views/stories/edit.html.erb_spec.rb and new.html.erb_spec.rb pass (23 examples, 0 failures).

Anything else to add?

The author select used Rails' prompt: option, which only renders the
placeholder when no value is selected. On an existing story the author
is already set, so no blank option existed and the field could not be
returned to 'Select an author'. Switch to include_blank: so the blank
option always renders, matching the new-story behavior.

Fixes #1517

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 5, 2026 00:36
<%= f.input :created_by_id,
collection: @users.map { |u| [ u.full_name_with_email, u.id ] },
prompt: "Select an author",
include_blank: "Select an author",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched from prompt: to include_blank: here. prompt: only renders the placeholder <option> when the field has no value, so on an already-set story the blank option was absent and the author couldn't be cleared. include_blank: always renders it — matching workshop_id/organization_id above.

@maebeale maebeale marked this pull request as ready for review June 5, 2026 00:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a UX bug on the story edit form where an already-selected Story author could not be cleared back to the placeholder option, by ensuring the blank <option> is always rendered even when a value is currently selected.

Changes:

  • Switches the Story author select from prompt: to include_blank: so the blank option exists on edit when an author is already set.
  • Adds a view spec to assert the edit form includes the blank author option needed to clear the selection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/views/stories/_form.html.erb Ensures the author select always renders a blank option so users can clear an existing selection.
spec/views/stories/edit.html.erb_spec.rb Adds coverage verifying the edit form renders the blank author option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edit story: can't deselect a story author to return to 'Select an author'

2 participants