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(overlays): focus trap refs cleared on dismiss #26855

Merged
merged 2 commits into from
Feb 27, 2023
Merged

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Feb 24, 2023

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Part of #26833

Our focus trapping util stores the last element that was focused in overlayEl.lastFocus. However, this is never cleared when the overlay is dismissed. This results in the overlay keeping a strong reference to some other element. lastFocus is only utilized while the overlay is presented, so we should clear it on dismiss.

What is the new behavior?

  • lastFocus is cleared when the overlay is dismissed.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@stackblitz
Copy link

stackblitz bot commented Feb 24, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions bot added the package: core @ionic/core package label Feb 24, 2023
@@ -8,7 +8,7 @@ export interface OverlayEventDetail<T = any> {
}

export interface OverlayInterface {
el: HTMLElement;
el: HTMLIonOverlayElement;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should always have been HTMLIonOverlayElement. Without it, I get typescript errors when trying to access lastFocus (since it is only known property of HTMLIonOverlayElement not HTMLElement)

@liamdebeasi liamdebeasi merged commit 8d1d0fa into main Feb 27, 2023
@liamdebeasi liamdebeasi deleted the clear-focus branch February 27, 2023 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants