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

[Accessibility]: Page looses focus after Search modal gets closed #9917

Closed
7 tasks done
mxschmitt opened this issue Mar 6, 2024 · 1 comment · Fixed by #9945
Closed
7 tasks done

[Accessibility]: Page looses focus after Search modal gets closed #9917

mxschmitt opened this issue Mar 6, 2024 · 1 comment · Fixed by #9945
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers

Comments

@mxschmitt
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

When entering the Search dialog of docusaurus and leaving it afterwards via ESC, the page looses focus and does not re-focus the search input box from before.

Relates microsoft/playwright.dev#1269.

Reproducible demo

No response

Steps to reproduce

  1. Navigate to https://docusaurus.io/
  2. Press Tab around 14 times, until the focus reaches the Search input box
  3. Press Enter
  4. Press ESC key

Expected behavior

Focus stays at the search input box.

Actual behavior

Focus gets lost.

Your environment

  • Public source code: N/A
  • Public site URL: N/A
  • Docusaurus version used: main
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 122
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS 14.3

Self-service

  • I'd be willing to fix this bug myself.
@mxschmitt mxschmitt added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Mar 6, 2024
@mxschmitt
Copy link
Contributor Author

mxschmitt commented Mar 6, 2024

Proposed fix: Doing searchButtonRef.current?.focus() here:

Alternatively we could focus the element here, which seems also reasonable:

https://github.com/algolia/docsearch/blob/df60b8ebe89c80ce3d00b80d94e95b6fd86edd19/packages/docsearch-react/src/useDocSearchKeyboardEvents.ts#L51

Any thoughts would be appreciated, happy to create a PR for it once clarified. The solution above seems to work.

Sounds related to algolia/docsearch#1370 but seems easily solvable in docusaurus land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@mxschmitt and others