Replace story author dropdown with a search box#1553
Conversation
The author dropdown rendered every accessible user as a <select> option, which grows unwieldy as the facilitator list expands and bloats every story new/edit page. Reuse the existing remote-select typeahead (already used for workshops and organizations) so authors can be found by typing, loading matches on demand via the User remote-search endpoint instead of preloading all users into the form. Fixes #1516 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| collection: @users.map { |u| [ u.full_name_with_email, u.id ] }, | ||
| prompt: "Select an author", | ||
| collection: f.object.created_by.present? ? [[ f.object.created_by.remote_search_label[:label], f.object.created_by.id ]] : [], | ||
| selected: f.object.created_by_id, |
There was a problem hiding this comment.
Seeds only the currently-selected author as the initial <option> (same pattern as the workshop/organization fields above). The full result set is fetched on demand from /search/user as the user types, so the form no longer renders every user.
| @@ -131,7 +131,6 @@ def set_form_variables | |||
| .references(:users) | |||
| .order(:created_at) | |||
| @people = Person.order(Arel.sql("LOWER(first_name), LOWER(last_name)")) | |||
There was a problem hiding this comment.
Removed the @users query that loaded and ordered every accessible user purely to populate the author dropdown. The remote-select field now fetches matches on demand, so this preload is no longer needed (other views that use @users set it themselves).
There was a problem hiding this comment.
Pull request overview
This PR updates the Story form to avoid rendering a huge “author” <select> by switching it to the existing TomSelect-powered remote-select behavior, querying authors on demand via the existing /search/user endpoint. This keeps the story new/edit pages responsive as the user list grows and removes an unnecessary controller query.
Changes:
- Replace the story
created_by_iddropdown collection with an initially-seeded, remote-search-enabled select (TomSelect viaremote-selectStimulus). - Seed the current author as the only initial option for persisted stories so the existing value displays immediately.
- Remove the now-unused
@userspreload query fromStoriesController#set_form_variables.
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 | Switches “Story author” to a remote-select (TomSelect) field with on-demand search and initial seeding for persisted records. |
| app/controllers/stories_controller.rb | Removes the full-user-list query previously used only to populate the author dropdown. |
Closes #1516
What is the goal of this PR and why is this important?
<select>containing every accessible user as an<option>How did you approach the change?
remote-selectStimulus controller (TomSelect) that already powers the workshop and organization fields on this same formcreated_by_idfield now loads matches on demand from the existingUserremote-search endpoint (/search/user) instead of pre-rendering all users@usersquery fromStoriesController#set_form_variables— it previously loaded and ordered every accessible user just to populate the dropdownUseralready implementsremote_search/remote_search_label,SearchControlleralready whitelistsuser, and story new/edit/create are admin-only (matching the search endpoint'sadmin?rule)UI Testing Checklist
created_by_id)Anything else to add?
spec/views/stories/newandedit) still pass — the server-rendered element remains a<select>(TomSelect enhances it client-side)