Open kark opened 5 months ago
The latest updates on your projects. Learn more about Vercel for Git βοΈ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
merchant-center-application-kit-components-playground | β Ready (Inspect) | Visit Preview | π¬ Add feedback | May 9, 2024 8:31am |
Latest commit: f289bba7ac96b867adab7e92a83dda4d3dbff710
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Summary
This PR addresses an issue encountered with the usage of the
useModalState
hook for managing modal state within our documentation. Currently, following the steps as outlined in the documentation snippets doesn't allow applying correct indentation levels for modals stacking layers due to a lack of DOM mutation events that can be picked up by the Mutation Observer used within the portals container.The problem is that following the steps from our snippets e.g.
doesn't really work (i.e.
Modal
component from thereact-modal
library technically triggers a DOM mutation, by applying a grandchild element of the portals container, but the Mutation Observer doesn't react to it).Until now the conditional rendering was the solution to make it work instead:
With this PR, whenever the
useModalState
hook is used to manage modal state andisModalState
changes, the necessary child-level DOM mutation is triggered. This ensures that the Mutation Observer can properly compute the correct indentation level for the modal's stacking layer.Alternatives considered
Technically there is a
subtree
option that can be passed to the Mutation Observerobserve
method call, but it didn't work either.I suspect it might be related to https://stackoverflow.com/a/61315048 but I felt that creating a custom Tree Walker is an overkill (but maybe that would be your preferred solution)