fix(theme/bootstrap): submit search when a home suggestion is clicked#3152
Merged
Conversation
On the bundled Bootstrap HTML theme's home (top) page, clicking a search suggestion only filled the input without running the search, while every other suggest path submits (default JSP suggestor.js, the results-page header suggest, and keyboard Enter/Tab). The shared attachSuggest() helper filled the input but never submitted. attachSuggest() is also used by the advanced search form, where auto-submitting on a single field would be wrong (other fields empty), so submission is opt-in via a new submitOnSelect option that only the home wiring enables. The advanced search path stays fill-only. Add BundledBootstrapThemeTest assertions covering the opt-in submit logic in search.js, the home opt-in in app.js, and that advance.js stays fill-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the bundled Bootstrap HTML theme, clicking a search suggestion on the home (top) page only filled the input without running the search — the user had to press the search button afterwards. Every other suggest path already submits:
js/suggestor.js),search.jsmousedownhandler), andThis was an inconsistency, not intended behavior: the home wiring comment even states it should reach "parity with index.jsp" (which submits). The root cause is that the shared
attachSuggest()helper inthemes/bootstrap/assets/search.jsfilled the input but never submitted the form.Why opt-in
attachSuggest()is also used by the advanced search form (advance.js, the "all words" input). There, auto-submitting when a single suggestion is clicked would be wrong because the other fields would still be empty. So submission is added as an opt-insubmitOnSelectoption that only the home page enables; advanced search stays fill-only.Changes
themes/bootstrap/assets/search.js—attachSuggest()gains an opt-insubmitOnSelectoption. When set, after filling the input it dispatches asubmitevent on the input's form (input.form/closest("form")), mirroring the results-page header handler. Default behavior is unchanged (fill-only).themes/bootstrap/assets/app.js— the home search box now passessubmitOnSelect: true. The existing#home-search-formsubmit handler navigates to/search, so dispatching submit runs the search.advance.js— unchanged (remains fill-only).BundledBootstrapThemeTest— 3 new assertions: home enables the opt-in (app.js), the submit logic exists (search.js), and advanced search stays fill-only (advance.js).Testing
mvn test -Dtest=BundledBootstrapThemeTest→ 110 passed (2 new tests were red before the fix, green after).Note: this repo has no JS unit-test framework, so verification uses the project's existing asset-content assertion style plus code review. A live browser run was not performed.