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

Disable autofocus of SearchBar for keyboard-navigation friendly #614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bootleq
Copy link

@bootleq bootleq commented Mar 10, 2025

Hi, this PR tries to address an accessibility issue:

Issue

I often visit twreporter site from shared links (mostly to Article pages), and notice that I can't use Page Up/Down or Home/End keys to scroll.

This only happens in first visited page, subsequent navigation works fine.

The cause is that "search" input in the header automatically gets focus and intercepts all keyboard input.

Even more frustratingly, sometimes scrolling works at first, but once the page fully loads, it suddenly jumped back to top, and such keys stop responding. (this PR doesn't resolve the jumping back behavior)

Clarification: I'm using Firefox. Chrome/Edge can response PageDown in this scenario, but still not Home/End.

Notice

Most component consumers already set autofocus to false, but pages using UniversalHeader (e.g., Article) have true.
It can be safely turned off because the focus behavior is already handled by handleClickSearch.

Dependency

None.

Should use autofocus sparingly with accessibility in mind.

- Change default value in SearchBar component, autofocus true => false.

- Still explicitly set autofocus prop in universal-header.
Copy link

vercel bot commented Mar 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 4:26am
twreporter-npm-packages-universal-header ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 4:26am
universal-header ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 4:26am

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.

1 participant