Skip to content

fix(overlays): focus trap refs cleared on dismiss - #26855

Merged
liamdebeasi merged 2 commits into
mainfrom
clear-focus
Feb 27, 2023
Merged

fix(overlays): focus trap refs cleared on dismiss#26855
liamdebeasi merged 2 commits into
mainfrom
clear-focus

Conversation

@liamdebeasi

@liamdebeasi liamdebeasi commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

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

@bolt-new-by-stackblitz

Copy link
Copy Markdown

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

export interface OverlayInterface {
el: HTMLElement;
el: HTMLIonOverlayElement;

Copy link
Copy Markdown
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 marked this pull request as ready for review February 24, 2023 18:28
@liamdebeasi
liamdebeasi requested a review from a team as a code owner February 24, 2023 18:28
@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