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(module:overlay): Interop delElementFrom() exception on page refresh #1008

Conversation

anddrzejb
Copy link
Member

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

💡 Background and solution

Commit 6ff010c

Removes js event handler firing on window resize from OverlayTrigger (this event handler is used to move the overlay as window resizes) on Dispose().

Commit be31e33

When Overlay is disposed, it tries to remove itself from the DOM. This works well when a page is changed using built in navigation or when a particular component is removed by the framework.
This does not work well when the page is for example refreshed or new address is typed manually, because the dispose method is trying to remove DOM element that no longer exists.
To recreate:

  • start the project npm start
  • navigate to https"//localhost:5001
  • navigate to components/tooltip
  • hover over any control that should have a tooltip (so the tooltip appears)
  • press F5
  • observe the console; in about a minute (at least in my dev machine it takes exactly a minute) the exception will pop:
    image

The problem was fixed by registering a js event beforeunload that when fired changes a private flag bool _isReloading. If this flag is set to true, the call to js delElementFrom is not firing during disposal.

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

@anddrzejb anddrzejb changed the title Interop del element from body exception fix(module:overlay): Interop delElementFrom() exception on page refresh for Overlay Jan 20, 2021
@anddrzejb anddrzejb changed the title fix(module:overlay): Interop delElementFrom() exception on page refresh for Overlay fix(module:overlay): Interop delElementFrom() exception on page refresh Jan 20, 2021
Copy link
Member

@ElderJames ElderJames left a comment

Choose a reason for hiding this comment

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

LGTM

@ElderJames ElderJames merged commit 0d7c486 into ant-design-blazor:master Jan 20, 2021
@anddrzejb anddrzejb deleted the interop_delElementFromBody_exception branch January 20, 2021 12:02
ElderJames pushed a commit that referenced this pull request Apr 23, 2022
…esh (#1008)

* fix(module:overlay): page reload detection

* fix(module:overlaytrigger): event handler on window resize remove on dispose
ElderJames pushed a commit that referenced this pull request Apr 30, 2022
…esh (#1008)

* fix(module:overlay): page reload detection

* fix(module:overlaytrigger): event handler on window resize remove on dispose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants