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 focus not always returning to expected element on active=false #139

Merged
merged 2 commits into from
Oct 22, 2020

Conversation

stefcameron
Copy link
Member

This is a new fix for the issue identified in #54 after gaining
a better understanding of the issue.

The returnFocusOnDeactivate flag was being special-cased, but
not always, and the element to which focus should be returned,
which focus-trap-react attempts to manage on its own (see
class Constructor comment for reasoning), was not always correct.
For example, if the trap was deactivated, and then re-activated,
the 'last focused element before activation' wasn't updated at
the moment of re-activation, where it could've changed.

Features and Bug Fixes

  • Issue being fixed is referenced.
  • Unit test coverage added/updated.
  • E2E test coverage added/updated.
  • Prop-types added/updated.
  • Typings added/updated.
  • README updated (API changes, instructions, etc.).
  • Changes to dependencies explained.
  • Changeset added (run yarn changeset locally to add one, follow prompts).

This is a new fix for the issue identified in #54 after gaining
a better understanding of the issue.

The `returnFocusOnDeactivate` flag was being special-cased, but
not always, and the element to which focus should be returned,
which focus-trap-react attempts to manage on its own (see
class Constructor comment for reasoning), was not always correct.
For example, if the trap was deactivated, and then re-activated,
the 'last focused element before activation' wasn't updated at
the moment of re-activation, where it could've changed.
@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2020

🦋 Changeset detected

Latest commit: 86b464f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@stefcameron
Copy link
Member Author

@maraisr What do you think about this? The issue is related to how this library special-cases the returnFocusOnDeactivate flag.

@maraisr
Copy link
Contributor

maraisr commented Oct 12, 2020

Ill take look tomorrow morning @stefcameron

@stefcameron
Copy link
Member Author

See more discussion on #54. Looks like this solution will work. Merging.

@stefcameron stefcameron merged commit 01653da into master Oct 22, 2020
@stefcameron stefcameron deleted the return-focus branch October 22, 2020 21:10
@github-actions github-actions bot mentioned this pull request Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug waiting Waiting for response from community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants