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

[#948] Add onPost/Pause and onPost/Unpause hooks #914

Merged
merged 2 commits into from
Mar 8, 2023
Merged

Conversation

stefcameron
Copy link
Member

@stefcameron stefcameron commented Mar 8, 2023

Fixes #948

We have onPost/Activate and onPost/Deactivate hooks, but equivalent (and useful) hooks for un/pausing traps don't exist.

The new hooks are called before/after critical moments in the un/pausing process.

Like the de/activation hooks, they can also be one-time overridden via a new options parameter in the trap's pause(options) and unpause(options) methods.

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 #948

We have onPost/Activate and onPost/Deactivate hooks, but equivalent (and useful)
hooks for un/pausing traps don't exist.

The new hooks are called before/after critical moments in the un/pausing process.

Like the de/activation hooks, they can also be one-time overridden via a new
`options` parameter in the trap's `pause(options)` and `unpause(options)`
methods.
@changeset-bot
Copy link

changeset-bot bot commented Mar 8, 2023

🦋 Changeset detected

Latest commit: 55f8eb9

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 Minor

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 da97007 into master Mar 8, 2023
@stefcameron stefcameron deleted the pause-hooks branch March 8, 2023 20:46
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.

Add onPost/Pause and onPost/Unpause hooks
1 participant