-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Modal
: Improve application of body class names
#55430
Conversation
const level0Dismissers: MutableRefObject< | ||
ModalProps[ 'onRequestClose' ] | undefined | ||
>[] = []; | ||
const ModalContext = createContext( level0Dismissers ); | ||
const ModalContext = createContext< | ||
MutableRefObject< ModalProps[ 'onRequestClose' ] | undefined >[] | ||
>( [] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A level0Dismissers
reference isn't needed anymore. It was added in #51602 only to maintain existing behavior. Now the effect for adding/removing body classes is nesting agnostic and simplified in that aspect.
Flaky tests detected in 29c962fa1bb6c34cae6bc6c06c18768f79eb9b43. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7263487451
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, tests well!
Good to go with a changelog 👍
29c962f
to
f4b2112
Compare
Thank you for reviewing Lena! |
* Add unit tests for body class name effects * Fix and enhance body class attribute effect * Add changelog entry
What?
Fixes up some obscure bugginess of the
bodyOpenClassName
prop and adds a couple unit tests to specify the expected behavior.Why?
To better specify the behavior and avoid potential future issues. It doesn't seem likely this is biting anyone but it could. I found this while working on #51602.
How?
Updates the logic to account for the fact that value of the prop may differ between subsequent modals and could potentially even be changed while a modal is open.
Testing Instructions
Manually
Snippet for manual testing in the Post editor
Automatically
npm run test:unit -- components/src/modal
.Screenshots or screencast
This demonstrates the two scenarios the added unit tests cover whereby the body class name is not currently added/removed as expected. The latter scenario is almost certainly never going to be encountered in the wild.
modal-body-class-fails.mp4