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

Refactor useMutationObserver hook to manage subtree modifications #2822

Closed
wants to merge 2 commits into from

Conversation

CarlosCortizasCT
Copy link
Contributor

Summary

Refactor useMutationObserver hook to manage subtree modifications.

Description

If we currently pass the subtree option to the useMutationObserver hook, we're not going to have our mutation callback called. This is because we can have a same MutationObserver observing different elements and, when we get the internal mutation callback in our hook, we check to see wether the mutated element is one of the ones we have previously registered.
In the case of adding a direct children to the observed element, that's not a problem; however, if we add a grandchildren to the observer element, consumers won't know about it because the mutated element will be an observer element child and we didn't registered those in our hook.

With this change, we introduce some changes for consumers to be allowed to be notified about nested elements mutated within the one registered in the hook.

In this first attempt, a selector is needed by the hook to check whether a mutated element is contained in the observed element.

@CarlosCortizasCT CarlosCortizasCT added the 🚧 Status: WIP Work in progress label May 20, 2024
Copy link

vercel bot commented May 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 4:43pm

Copy link

changeset-bot bot commented May 20, 2024

⚠️ No Changeset found

Latest commit: a930c3d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CarlosCortizasCT
Copy link
Contributor Author

Closing as this PoC was abandoned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 Status: WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant