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

added 'tab' accessibility to modal with focus lock to prevent from fo… #1575

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

simona1245
Copy link

as of the documentation and thorough internet searching about "tab focusing" it is clear that creating tab focus from scratch is not applicable. (see stackoverflow)

Library to add: react-focus-trap

@netlify
Copy link

netlify bot commented Dec 11, 2022

Deploy Preview for evergreen-storybook ready!

Name Link
🔨 Latest commit 82e23dd
🔍 Latest deploy log https://app.netlify.com/sites/evergreen-storybook/deploys/639784d5b8f1b10008030fb4
😎 Deploy Preview https://deploy-preview-1575--evergreen-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -63,13 +63,13 @@ const TableVirtualBody = memo(function TableVirtualBody(props) {
if (props.height !== calculatedHeight) {
setIsIntegerHeight(Number.isInteger(props.height))
}
}, [props.height])
}, [props.heightm, calculatedHeight])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert this file?

@@ -97,6 +98,16 @@ const Dialog = memo(function Dialog({
const topOffsetWithUnit = Number.isInteger(topOffset) ? `${topOffset}px` : topOffset
const maxHeight = `calc(100% - ${topOffsetWithUnit} * 2)`

const [isVisible, setIsVisible] = useState(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this is used for? (Is there a reason we can't use isShown from props?)

{renderHeader(close)}

<Pane
data-state={state}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we needed to move some of these props down? (I'd say we probably only need data-state set once in here either way)

@brandongregoryscott
Copy link
Contributor

Thanks for taking a look at this @simona1245!

I pulled it down and gave it a run myself, and it does seem to trap focus as expected. One potential issue I noticed is that it no longer closes the dialog when you click outside of it. I'm not entirely sure whether we should have this behavior, but it will be a breaking change if we keep it as-is. I'm going to dig into web accessibility standards a bit and see what I can find.

@brandongregoryscott
Copy link
Contributor

Hmm, after taking a look at what Paste does, they actually split out two variants of what looks like our Dialog component that are for different use cases:

https://paste.twilio.design/components/modal

This seems to be more or less our Dialog component, i.e. it closes on an outside click (but it is accessible in that it traps focus inside, handles escape to close, etc)

https://paste.twilio.design/components/alert-dialog

I think this is closer to what the proposed implementation in this PR is - same visual styling as their Modal component, but closing the AlertDialog has to be explicitly done with the Cancel/Confirmation action (escape does not close it either).

We're in somewhat of a middle state between these two variants. In the interest of backwards compatibility, can we figure out how to maintain the outside-click-to-close behavior?

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.

None yet

2 participants