Release 2290
Trello card
Context
The search page is not displaying any validation errors, instead it submit the data to the search results page and then it gets redirected back to the search page.
Changes proposed in this pull request
- Reduce time before search input loads: Sometimes, there is a very brief flash of blankness while the autocomplete loads. Swap the order of loading, so that the input is shown before the Google script is loaded.
- Apply GOV.UK styling to accessible autocomplete in CSS: I was previously applying the styling in JavaScript, but the accessible autocomplete was reloading when its state changed, so was losing the class.Sass comes with an @extend rule, so use that instead.
- Make sure validation errors are shown when user doesn't enter a value: Currently, when a user doesn't enter a search value, they are redirected back to the
newpage, but not shown a validation error. Checkvalid?andlocation_present?in the same line to make sure validation is shown properly. - Show error messages when JavaScript enabled: We want to show error messages on the location search when JavaScript is enabled. I have previously done this as a Rails partial, but it was easier to do it here in the Stimulus controller.
- Make sure blank message shows if search is blank: Currently, the search shows the too_short message when the search is blank. Update it so that it shows the correct message.
Guidance to review
This still send you back to the new search page if there is an error (which is what the ticket says to do). It looks weird if we show the error on the index page.