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

Bug: Put contentRef in state to let EventStack track changes #4388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GuiCodron
Copy link

contentRef is passed to EventStack to subscribe for mouse events.
Passing a contentRef created using React.createRef() does not allow EventStack to keep track of contentRef changes (since only contentRef.current changes).
Ultimately when PortalInner unmount contentRef.current is set to undefined and EventStack unsubscribe handlers with undefined as a target instead of unsubscribing with real content. This leads to the event-stack Map keeping a reference to the real content thus leaking all dom tree related to the contentRef node.

Putting contentRef in the state and passing the element directly to EventStack allow for EventStack to detect change in its props and execute the componentDidUpdate routine which unsubscribe from the previous element on unmount.

contentRef is passed to EventStack to subscribe for mouse events.
Passing a `contentRef` created using `React.createRef()` does not allow
EventStack to keep track of contentRef changes (since only
contentRef.current changes).
Ultimately when PortalInner unmount contentRef.current is set to undefined
and EventStack `unsubscribe` handlers with `undefined` as
a target instead of unsubscribing with real content.
This leads to the event-stack Map keeping a reference to the real contentRef
thus leaking all dom tree related to the node related to contentRef.

Putting contentRef in the state and passing the element allow for
EventStack to detect change in props and execute the componentDidUpdate
routine which unsubscribe from the previous element on unmount.
@welcome
Copy link

welcome bot commented Oct 13, 2022

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Run yarn lint locally to catch formatting errors. This will fix some errors automatically, commit and push any changes.
  • Run yarn test locally to catch errors. This ensures all components still behave as they should.
  • Run yarn start to run the doc site locally and try a few pages, ensuring everything is in good working order.
  • Include tests when adding/changing behavior.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

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.

1 participant