Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search bug on foreign travel advice page #4079

Merged

Conversation

CodeSonia
Copy link
Contributor

@CodeSonia CodeSonia commented May 23, 2024

What

  • Added a keydown event listener to the CountryFilter function to prevent the default form submission behaviour when the Enter key is pressed.
  • Kept the keyup event listener to handle filtering functionality
  • The test case in foreign_travel_advice_spec.js now checks for keydown event instead of keyup when Enter key is pressed.
  • Changes on the integration test file travel_advice_test.rb where assertions are updated to reflect the visibility changes in the country list items.

Why

Trello card

Previously, the keyup event listener was solely responsible for handling both form submission prevention and filtering. However, a bug was found where if you typed "Spain" in the search and press Enter, the results are cleared and the URL retains the search term.

Visual Changes

Before After
image image

@CodeSonia CodeSonia marked this pull request as draft May 23, 2024 11:23
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4079 May 23, 2024 11:30 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4079 May 23, 2024 14:16 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4079 May 29, 2024 12:54 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4079 May 29, 2024 12:56 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4079 May 30, 2024 12:33 Inactive
- Adds a keydown event listener to the CountryFilter function. The event listener triggers on keydown and prevents the default form behaviour when the Enter key is pressed and cleared the results.

- Keyup event listener is retained to handle filtering functionality
@CodeSonia CodeSonia force-pushed the fix-bug-search-behavior-on-foreign-travel-advice-page branch from b93d714 to 0a5d623 Compare May 30, 2024 12:45
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4079 May 30, 2024 12:46 Inactive
@CodeSonia CodeSonia changed the title Fix: use keydown instead of keyup in CountryFilter Fix search bug on foreign travel advice page May 30, 2024
@CodeSonia CodeSonia marked this pull request as ready for review May 30, 2024 14:55
Copy link
Contributor

@MartinJJones MartinJJones left a comment

Choose a reason for hiding this comment

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

Nice work!, the changes look good to me 👍

@MartinJJones MartinJJones merged commit 4999951 into main May 31, 2024
12 checks passed
@MartinJJones MartinJJones deleted the fix-bug-search-behavior-on-foreign-travel-advice-page branch May 31, 2024 08:56
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.

None yet

3 participants