-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[ModalUnstyled] Fix behavior of not respecting props ariaHidden value #32055
Conversation
Fixed in ModalManager too. |
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.
Changes look good, let's add test to ensure it won't break again in the future :)
@tech-meppem could you add tests for the fix? |
Hi This is the code I added: it('forwards the ariaHidden prop', () => {
const elementRef = React.createRef();
// by default, aria-hidden == !open
// so test the inverses of that
const { setProps } = render(
<ModalUnstyled
open
aria-hidden
ref={elementRef}
keepMounted
data-testid="modal"
>
<div />
</ModalUnstyled>,
);
const { current: element } = elementRef;
expect(element.getAttribute('aria-hidden'), 'true when modal open').to.equal('true');
setProps({
open: false,
"aria-hidden": false,
});
const elementPost = screen.getByTestId('modal');
expect(elementPost.getAttribute('aria-hidden'), 'null when modal closed').to.equal(null);
}); However, a problem occurs in that when I change the props with setProps, the HTML dom has not been re-rendered before I do the next check. |
Take a look at the Modal's test for patterns on how to write the tests. In this specific case, I would just write two different tests, it would even be more readable. |
I've updated it now, and have added 4 tests, for all 4 use cases (open/close + set via props/not set via props). |
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.
Looks great, thanks for spending time on it :)
Fix for Modal ariaHidden prop as stated in issue #32029.
Fixes #32039
It is using
props.ariaHidden
directly because there was a eslint error putting it in theconst {} = props
above.