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

[popover] Fix stuck focus #609

Merged
merged 1 commit into from Jun 12, 2020
Merged

Conversation

michaeldfoley
Copy link
Contributor

When the targetRef is the last tabbable element outside the popover, getElementAfterTrigger returns the first tabbable element inside the portal causing the focus to stay trapped inside the popover. What we want is for getElementAfterTrigger to return an element only if it is not inside the popover.

Thank you for contributing to Reach UI! Please fill in this template before submitting your PR to help us process your request more quickly.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code (Compile and run).
  • Add or edit tests to reflect the change (Run with yarn test).
  • Add or edit Storybook examples to reflect the change (Run with yarn start).
  • Ensure formatting is consistent with the project's Prettier configuration.

This pull request:

  • Creates a new package
  • Fixes a bug in an existing package
  • Adds additional features/functionality to an existing package
  • Updates documentation or example code
  • Other

If creating a new package:

  • Make sure the new package directory contains each of the following, and that their structure/formatting mirrors other related examples in the project:
    • examples directory
    • src directory with an index.tsx entry file
    • At least one example file per feature introduced by the new package
    • Base styles in a style.css file (if needed by the new package)

@michaeldfoley michaeldfoley changed the title [popover] Fix stuck tab (#545) [popover] Fix stuck focus Jun 6, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 6, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b656d2b:

Sandbox Source
laughing-chatterjee-hube6 Configuration

@chaance
Copy link
Member

chaance commented Jun 11, 2020

@michaeldfoley Can you reproduce a test case using the CodeSandbox link generated above? I'm happy to merge this if I can get a better understanding of the problem with a simple example.

@michaeldfoley
Copy link
Contributor Author

In this example the focus gets stuck in the popover when there are no tabbable items after the targetRef.

Here is the same example with my PR applied. After the popup, the focus moves into the chrome as expected.

@chaance
Copy link
Member

chaance commented Jun 12, 2020

Looks good to me, thank you!

@chaance chaance added the Type: Bug Something isn't working label Jun 12, 2020
@chaance chaance merged commit 8a09b9e into reach:master Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants