-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Transition] Fix hidden children appearing in a11y tree #14465
[Transition] Fix hidden children appearing in a11y tree #14465
Conversation
5704135
to
d7ea6b7
Compare
d7ea6b7
to
63e91ac
Compare
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.
Failing test are IMO expected. If you don't want to mount if in={false}
then react-transition-group
provides mountOnEnter={false}
We have a problem with the focus logic. A visibility hidden element can't receive the focus. Now, the problem is that our Modal, Dialog, Menu components don't wait for the transition to start to focus the children, hence it's not working. The Firefox 52 test fail is just a symptom, you could see that the dialog autofocus logic was broken too on Chrome latest. There is no quick win here, it's a difficult problem to solve. I think that we can think of a solution handle:
|
05c6913
to
2618e1e
Compare
I think the issue is that those components set the The good thing is that this was always an issue that might've caused some subtle bugs. The bad thing is that we also need to fix dependent components. |
github UI is broken for this PR. It shows 41 commits and 600 files changed while compare correctly shows only 23 commits and 12 files changed. Going to squash it. History is saved locally. |
Squashed commit of the following: commit 491239f60e7cf1769ef159ee447df9001fe63f46 Merge: bf011ce aad72ed Author: Sebastian Silbermann <[email protected]> Date: Wed Feb 13 10:29:31 2019 +0100 Merge branch 'next' into docs/a11y-code-variant-switch commit bf011ce Author: Sebastian Silbermann <[email protected]> Date: Tue Feb 12 21:13:26 2019 +0100 [Collapse] Don't consider hidden if collapsedHeight > 0 commit 59ee3e5 Author: Sebastian Silbermann <[email protected]> Date: Tue Feb 12 21:07:36 2019 +0100 [Collapse] Fix css hidden property name commit 32dd6ff Merge: a2d6e83 2618e1e Author: Sebastian Silbermann <[email protected]> Date: Tue Feb 12 21:03:44 2019 +0100 Merge branch 'docs/a11y-code-variant-switch' of github.com:eps1lon/material-ui into docs/a11y-code-variant-switch commit a2d6e83 Author: Sebastian Silbermann <[email protected]> Date: Sat Feb 9 11:03:56 2019 +0100 [core] Normalize transitions child style implementation commit 8d16305 Author: Sebastian Silbermann <[email protected]> Date: Sat Feb 9 09:05:49 2019 +0100 fixup commit ae08e11 Author: Sebastian Silbermann <[email protected]> Date: Sat Feb 9 09:05:34 2019 +0100 fixup commit 7b2cae2 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 20:27:43 2019 +0100 [Slide] Fix tests commit 9cdb582 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 20:19:01 2019 +0100 [core] Normalize transitions API commit 752cde5 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 16:31:28 2019 +0100 [Fade] Fix display none on IE 11 commit d10309b Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 14:22:31 2019 +0100 [Fade] Fix propTypes not warning on missing child element commit 1ed6682 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 14:21:44 2019 +0100 [Fade] Fix child element appearing in the a11y tree if hidden visually commit 6cbaabe Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 14:17:39 2019 +0100 [Fade] Test a11y for invisible content commit 2618e1e Author: Olivier Tassinari <[email protected]> Date: Sun Feb 10 10:49:22 2019 +0100 change class name commit ef1e87a Author: Olivier Tassinari <[email protected]> Date: Sun Feb 10 01:55:34 2019 +0100 look into the build fail commit af3d812 Author: Sebastian Silbermann <[email protected]> Date: Sat Feb 9 11:03:56 2019 +0100 [core] Normalize transitions child style implementation commit 5082f2f Author: Sebastian Silbermann <[email protected]> Date: Sat Feb 9 09:05:49 2019 +0100 fixup commit 32699b1 Author: Sebastian Silbermann <[email protected]> Date: Sat Feb 9 09:05:34 2019 +0100 fixup commit 459b8f8 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 20:27:43 2019 +0100 [Slide] Fix tests commit 5dba229 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 20:19:01 2019 +0100 [core] Normalize transitions API commit 63e91ac Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 16:31:28 2019 +0100 [Fade] Fix display none on IE 11 commit fb70b73 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 14:22:31 2019 +0100 [Fade] Fix propTypes not warning on missing child element commit 85d75ce Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 14:21:44 2019 +0100 [Fade] Fix child element appearing in the a11y tree if hidden visually commit 658b4d3 Author: Sebastian Silbermann <[email protected]> Date: Fri Feb 8 14:17:39 2019 +0100 [Fade] Test a11y for invisible content
bf011ce
to
61a6d0d
Compare
Quick update regarding FF 52 focus issue: It does work properly in browserstack and fiddling with https://deploy-preview-14465--material-ui.netlify.com/demos/menus/#simple-menu. I suspect in the test the menu is still hidden. Other browsers can focus that content while FF cannot. |
@eps1lon It's not related to Firefox, it's broken for everybody: #14465 (comment). |
I was speaking about the build failure. What do you mean? I did not understand that comment:
This is intended. This is the purpose of this PR: Hidden elements should not be focusable.
They don't transition into Could you explain what is currently not working? Elements seem to receive focus just fine when manually testing keyboard focus on https://deploy-preview-14465--material-ui.netlify.com/demos/menus/#simple-menu |
@oliviertassinari What browser? Debug notes (limited to
<div
class="MuiPaper-root-7 MuiMenu-paper-1 MuiPaper-elevation8-17 MuiPaper-rounded-8 MuiPopover-paper-2"
data-mui-test="Popover"
aria-hidden="false"
role="document"
tabindex="-1"
style="opacity: 1; transform: scale(1, 1); transition: opacity 0ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 0ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; top: 16px; left: 16px; transform-origin: -8px -8px;"
>
<ul
class="MuiList-root-34 MuiList-padding-35"
role="menu"
data-mui-test="Menu"
>
<li
class="MuiButtonBase-root-53 MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 MuiListItem-button-50 MuiMenuItem-root-38 MuiMenuItem-gutters-39"
tabindex="0"
role="menuitem"
>
Menu Item 1<span class="MuiTouchRipple-root-56" />
</li>
<li
class="MuiButtonBase-root-53 MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 MuiListItem-button-50 MuiMenuItem-root-38 MuiMenuItem-gutters-39"
tabindex="-1"
role="menuitem"
>
Menu Item 2<span class="MuiTouchRipple-root-56" />
</li>
<li
class="MuiButtonBase-root-53 MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 MuiListItem-button-50 MuiMenuItem-root-38 MuiMenuItem-gutters-39"
tabindex="-1"
role="menuitem"
>
Menu Item 3<span class="MuiTouchRipple-root-56" />
</li>
</ul>
</div>; Firefox 52: <div
class="MuiPaper-root-7 MuiMenu-paper-1 MuiPaper-elevation8-17 MuiPaper-rounded-8 MuiPopover-paper-2"
data-mui-test="Popover"
aria-hidden="false"
style="opacity: 1; transform: scale(1, 1); transition: opacity 0ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 0ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; top: 16px; left: 16px; transform-origin: -8px -8px 0px;"
role="document"
tabindex="-1"
>
<ul
class="MuiList-root-34 MuiList-padding-35"
role="menu"
data-mui-test="Menu"
>
<li
class="MuiButtonBase-root-53 MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 MuiListItem-button-50 MuiMenuItem-root-38 MuiMenuItem-gutters-39"
tabindex="0"
role="menuitem"
>
Menu Item 1<span class="MuiTouchRipple-root-56" />
</li>
<li
class="MuiButtonBase-root-53 MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 MuiListItem-button-50 MuiMenuItem-root-38 MuiMenuItem-gutters-39"
tabindex="-1"
role="menuitem"
>
Menu Item 2<span class="MuiTouchRipple-root-56" />
</li>
<li
class="MuiButtonBase-root-53 MuiListItem-root-41 MuiListItem-default-44 MuiListItem-gutters-49 MuiListItem-button-50 MuiMenuItem-root-38 MuiMenuItem-gutters-39"
tabindex="-1"
role="menuitem"
>
Menu Item 3<span class="MuiTouchRipple-root-56" />
</li>
</ul>
</div>; only diff at the possition of the inline style attribute. However Firefox has the element with the |
Caused by focus() call race condition: dialog -> item in chrome but item -> dialog in firefox
Firefox issue is resolved. Investigating why opening a |
The issue was that the 3887ae4 added additional logic to handle this case. @oliviertassinari Could you verify if the issue you reported still exists? |
aria-hidden
andvisibility: hidden
ifexited
=> children are not part of the a11y tree and not focusibleI observed that the code variant switches in our docs were still focusable. This is due to Fade simply setting opacity to 0 which has not effect on the a11y tree.
Videos taken in chrome 72
production:
PR:
Behavior verified in latest chrome, firefox, edge and IE 11 (safari is not working in browserstack).
By setting thehidden
html prop they should automatically disappear but this will setdisplay: none
by spec. However by settingdisplay: initial
the children are focusable again. Only by settingvisibility: hidden
do we achieve that we keep the previous layout behavior and remove the content from the a11y tree.Sets the
aria-hidden
property for screenscreaders and sets visibility tohidden
to remove the childs from the tab order.Nice side effect: In Concurrent React theWe can't usehidden
attribute will cause React to render the content with lower priority.hidden
because that will causedisplay: none
. This was the original implementation butdisplay: initial
is not supported in IE 11Also removed some redundant prop type validation for children and marked it as required similar to #14444
Going to add this to the other transitions. Would close #12632