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

Dialog contents focusable when dialog is hidden #71

Open
GuiRitter opened this issue Jun 18, 2018 · 7 comments
Open

Dialog contents focusable when dialog is hidden #71

GuiRitter opened this issue Jun 18, 2018 · 7 comments

Comments

@GuiRitter
Copy link

Hi everyone.

With the dialog visible or hidden, it's possible to press the Tab key until the dialog contents have focus, enabling them to be interacted with.

I believe this should be prevented, since it enables the user to interact with systems in ways the programmers might not be expecting, leading into, in a best case scenario, bad user experience and, in a worst case scenario, actions that violate security, privacy, etc.

Here's a CodeSandBox that reproduces the issue. To reproduce it, press the Tab key until the open modal button is selected. This might require that the text be focused or selected beforehand. Then press the Tab key once to select the button inside the modal. Then press Enter or Space Bar to execute the action that should be unavailable.

Thanks in advance.

@marcio
Copy link
Owner

marcio commented Jun 19, 2018

Hi @GuiRitter

Thanks for report the issue, at the end, skylight works with display: block | none, then, the modal dom is always in you context, visible or hidden.

I'm not sure that prevent all fields/buttons inside a modal is a feature, maybe the devs can avoid this "problem" (when happen), just putting a tabindex="-1" in your fields/buttons when is hidden.

But I'll think about this, maybe with an optional prop, I don't now.

I'll keep the issue open to analyze.

🤘

@NicoleRauch
Copy link

Today I was wondering about something similar: Why don't you simply render nothing when the dialog is invisible, instead of rendering it with display: none?

What I mean is something like:

render() {
     return dialogIsNotVisible ? null : 
     <ContentsOfReactSkylightAsBefore>...</ContentsOfReactSkylightAsBefore>;
}

That would also reduce the amount of generated HTML in cases where many dialogs are rendered but only one is visible at a time.

@GuiRitter
Copy link
Author

GuiRitter commented Nov 26, 2018

Today I was wondering about something similar: Why don't you simply render nothing when the dialog is invisible, instead of rendering it with display: none?

What I mean is something like:

render() {
     return dialogIsNotVisible ? null : 
     <ContentsOfReactSkylightAsBefore>...</ContentsOfReactSkylightAsBefore>;
}

That would also reduce the amount of generated HTML in cases where many dialogs are rendered but only one is visible at a time.

Sure, that works, but it seems to me like this is something that skylight should implement, not us, even if only as courtesy,

@NicoleRauch
Copy link

Oh @GuiRitter , I'm super-sorry! This was badly worded and I did not intend to address you but instead React-Skylight... Let me try again, please.

@NicoleRauch
Copy link

Today I was wondering about something similar: Why doesn't react-skylight simply render nothing when the dialog is invisible, instead of rendering it with display: none?

What I mean is something like:

render() {
     return dialogIsNotVisible ? null : 
     <ContentsOfReactSkylightAsBefore>...</ContentsOfReactSkylightAsBefore>;
}

That would also reduce the amount of generated HTML in cases where many dialogs are rendered but only one is visible at a time.
What do you think @marcio ?

@GuiRitter
Copy link
Author

@NicoleRauch Don't worry, I didn't took it negatively nor nothing like that.

@OZZlE
Copy link

OZZlE commented Mar 20, 2019

It's not great for Screen Readers such as VoiceOver, if you have a website in the US then by law it needs to work for blind people as well.

Currently elements inside the popup are focusable when it's closed, Voice Over on Mac reads the whole popup when I tested.

Another issue is that when the popup is opened then Voice Over can focus on elements outside the popup as well, so it's not clear to a blind person that they have opened a popup and it doesn't read it first. I made workarounds in my own wrapper component for popups but it would be great if this module could handle it instead :)

Also since the close button is a charecter it reads "button middle cross" which doesn't make sense, it would probably be better if it was an image with a hidden text (read by SR) or a link with title text. Where the text is "Close dialog" or so, should be translatable as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants