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: indentation level of modals #3515

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kark
Copy link
Contributor

@kark kark commented May 7, 2024

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.

<FormModalPage
      isOpen={formModalState.isModalOpen}

doesn't really work (i.e. Modal component from the react-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:

{formModalState.isModalOpen && <FormModalPage
      isOpen

With this PR, whenever the useModalState hook is used to manage modal state and isModalState 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.
image

Before After
2024-05-07 14 35 27 2024-05-08 11 26 44

Alternatives considered

Technically there is a subtree option that can be passed to the Mutation Observer observe 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)

Copy link

vercel bot commented May 7, 2024

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

Copy link

changeset-bot bot commented May 7, 2024

🦋 Changeset detected

Latest commit: f289bba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@commercetools-frontend/application-components Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/codemod Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-frontend/react-notifications Patch
@commercetools-applications/merchant-center-template-starter-typescript Patch
@commercetools-applications/merchant-center-template-starter Patch
@commercetools-applications/merchant-center-custom-view-template-starter-typescript Patch
@commercetools-applications/merchant-center-custom-view-template-starter Patch
@commercetools-local/playground Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/components-playground Patch
@commercetools-frontend/cypress Patch
@commercetools-backend/eslint-config-node Patch
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/constants Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/eslint-config-mc-app Patch
@commercetools-frontend/i18n Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/l10n Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/sentry Patch
@commercetools-frontend/url-utils Patch

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

@kark kark closed this May 7, 2024
@kark kark reopened this May 8, 2024
@kark kark force-pushed the SHIELD-1088-fix-indentation-level-of-modeals branch from 8a947de to 1589f38 Compare May 8, 2024 08:58
@kark kark changed the title fix: indendation level of modals fix: indentation level of modals May 8, 2024
@kark kark force-pushed the SHIELD-1088-fix-indentation-level-of-modeals branch from 1589f38 to 1209eaa Compare May 8, 2024 09:08
@kark kark marked this pull request as ready for review May 9, 2024 08:46
@kark kark requested a review from a team as a code owner May 9, 2024 08:46
@CarlosCortizasCT CarlosCortizasCT removed the 🚧 Status: WIP Work in progress label May 9, 2024
@kark kark marked this pull request as draft May 15, 2024 08:47
@kark kark removed the request for review from a team May 15, 2024 11:25
@kark kark marked this pull request as ready for review May 20, 2024 13:32
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.

2 participants