Skip to content

(fix) Make quick search work in Safari#5383

Open
aulterego wants to merge 1 commit intoHDInnovations:developmentfrom
aulterego:fix/safari-quick-search
Open

(fix) Make quick search work in Safari#5383
aulterego wants to merge 1 commit intoHDInnovations:developmentfrom
aulterego:fix/safari-quick-search

Conversation

@aulterego
Copy link
Copy Markdown

The quick search bar on the home page doesn't work on Safari (macOS). Neither pressing return nor clicking on a completion result triggers any action. This is because Safari does not focus elements on click (macOS convention) and does not reliably bubble :active to ancestor elements. This caused the CSS :focus-within/:active visibility rule to hide the dropdown before the click event could complete navigation.

The fix is to:

  • Add x-on:mousedown.prevent on result links to retain input focus
  • Add Enter key handler to navigate to the first search result

Also while I'm here we can also:

  • Add null-safety to arrow key focus methods

I've run the project locally and have confirmed the fix works in Safari and does not cause a regression in Firefox.

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Apr 8, 2026

PR Summary

  • New event listener implementation
    Allows automatic navigation to first search result when 'Enter' key is pressed.
  • Anchor tag modification
    Prevents default action on mouse clicks to enhance navigation experience.
  • New method: navigateToFirstResult
    Aims to redirect to the first search result's URL when available.
  • Enhancements in existing methods
    Improves the focusFirstResult and focusLastResult methods to prevent any unexpected errors when accessing elements.

@aulterego aulterego changed the title fix: Safari quick search not working (fix) Safari quick search not working Apr 8, 2026
@aulterego aulterego changed the title (fix) Safari quick search not working (fix) Make quick search work in Safari Apr 8, 2026
Comment on lines +98 to +102
navigateToFirstResult() {
if (Array.isArray(this.searchResults) && this.searchResults.length > 0) {
window.location.href = this.searchResults[0].url;
}
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you move this to a separate commit and PR? It doesn't seem related to the rest of the code (although a useful addition nonetheless).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done! #5384

Safari does not focus <a> elements on click (macOS convention) and does
not reliably bubble :active to ancestor elements. This caused the
CSS :focus-within/:active visibility rule to hide the dropdown before
the click event could complete navigation.

- Add x-on:mousedown.prevent on result links to retain input focus
- Add null-safety to arrow key focus methods
@aulterego aulterego force-pushed the fix/safari-quick-search branch from a6662fe to 08cb27d Compare April 9, 2026 09:57
@Roardom
Copy link
Copy Markdown
Collaborator

Roardom commented Apr 9, 2026

Thanks!

@HDVinnie do you mind comparing a before and after on your mac when you have a chance?

@Roardom Roardom requested a review from HDVinnie April 9, 2026 10:11
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.

2 participants