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

[#893] Fix incorrect returnFocusOnDeactivate=true behavior #899

Merged
merged 1 commit into from
Feb 15, 2023

Conversation

stefcameron
Copy link
Member

Fixes #893

If clickOutsideDeactivates=true along with the return focus option being true and the outside click is on a focusable node, focus was returning to that node instead of the node originally focused prior to activation.

Now the returnFocusOnDeactivate option does exactly what it says it will do instead of the seemingly well-intentioned (based on the comment that was removed) behavior.

PR Checklist

Please leave this checklist in your PR.

  • Source changes maintain stated browser compatibility.
  • Includes updated docs demo bundle if source/docs code was changed (run yarn demo-bundle in your branch and include the /docs/demo-bundle.js file that gets generated in your PR).
  • Issue being fixed is referenced.
  • Unit test coverage added/updated.
  • E2E (i.e. demos) test coverage added/updated.
    • ⚠️ Non-covered demos (look for // TEST MANUALLY comments here) that can't be fully tested in Cypress have been manually verified.
  • Typings added/updated.
  • Changes do not break SSR:
    • Careful to test typeof document/window !== 'undefined' before using it in code that gets executed on load.
  • README updated (API changes, instructions, etc.).
  • Changes to dependencies explained.
  • Changeset added (run yarn changeset locally to add one, and follow the prompts).
    • EXCEPTION: A Changeset is not required if the change does not affect any of the source files that produce the package bundle. For example, demo changes, tooling changes, test updates, or a new dev-only dependency to run tests more efficiently should not have a Changeset since it will not affect package consumers.

Fixes #893

If `clickOutsideDeactivates=true` along with the return focus option being
`true` and the outside click is on a focusable node, focus was returning to
that node instead of the node originally focused prior to activation.

Now the `returnFocusOnDeactivate` option does exactly what it says it will
do instead of the seemingly well-intentioned (based on the comment that was
removed) behavior.
@changeset-bot
Copy link

changeset-bot bot commented Feb 15, 2023

🦋 Changeset detected

Latest commit: 78dd930

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

This PR includes changesets to release 1 package
Name Type
focus-trap Patch

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 stefcameron merged commit a27ad58 into master Feb 15, 2023
@stefcameron stefcameron deleted the return-focus branch February 15, 2023 17:26
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.

returnFocusOnDeactivate not working on mobile.
1 participant