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

fix(FocusLock): Stop stealing focus when embedded #9229

Merged
merged 2 commits into from
May 18, 2021

Conversation

muscat1
Copy link
Member

@muscat1 muscat1 commented May 17, 2021

No description provided.

@muscat1
Copy link
Member Author

muscat1 commented May 17, 2021

Hey, @skolmer could you PTAL at this too? I'm undoing a change (see screenshot) that was part of your Atlaskit overhaul a while back as it ended up not working as expected, namely focus is still being stolen when the conference is embedded and dialogs are rendered. I'm not sure if this messes something else up, so please let me know. I also didn't find the crossFrame prop documented in the focus-lock docs...

Screenshot 2021-05-17 at 13 08 37

@skolmer
Copy link
Contributor

skolmer commented May 17, 2021

Hi @muscat1, I might have missed an edgecase here.

The expected behavior is: If modal dialogs are shown the focus should move to the dialog. Locking focus to dialogs is a requirement to achieve WCAG 2 compliance.

Can you give an example where this causes issues? It should only be active for modal dialogs that are opened by a user action not for alerts or other stuff that are triggered without user input. So when it triggers the user focus should already be inside of jitsi and not the outer frame.

You are right it is not well documented. You can read about it in this PR theKashey/react-focus-lock#104
theKashey/react-focus-lock@486a7e0#diff-5bcff6869f846f5d731ec69050b8aa8ec92acd9d592a64b89504dda7f63dbd96R29

@skolmer
Copy link
Contributor

skolmer commented May 17, 2021

To ensure that focus-lock is only active when the jtsi frame has focus we could use https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus to check if the document has focus and otherwise disable focus-lock.

@muscat1
Copy link
Member Author

muscat1 commented May 17, 2021

Thanks for the quick reply @skolmer. I drew up a quick example here: https://jsbin.com/lizoguqiru/edit?html,output
The input below can't be focused when a modal is open in the iframe. Yeah, maybe we need to look into identifying whether the frame is in focus or not in order to decide whether we enable this or not.

@muscat1
Copy link
Member Author

muscat1 commented May 17, 2021

Also, thanks for pointing out the actual feature. From what it states, it should be enough for our use case, but by running a quick npm ls, Atlaskit seems to be using an outdated version of the library, so that feature is missing entirely.

@skolmer
Copy link
Contributor

skolmer commented May 17, 2021

Also, thanks for pointing out the actual feature. From what it states, it should be enough for our use case, but by running a quick npm ls, Atlaskit seems to be using an outdated version of the library, so that feature is missing entirely.

oh, that might explain it. I added the newest version to the package.json but can't find it in the current master nor in the PR we provided. It might have got lost on the way, sorry for that 🤦‍♂️

@muscat1 muscat1 force-pushed the muscat/dialog-focus branch from cd19e89 to 757b340 Compare May 17, 2021 12:29
@muscat1
Copy link
Member Author

muscat1 commented May 17, 2021

Seems to have done the trick, thanks for taking the time to look into it! I had to convert the wrapper to a function component (which I like, anyway) since react-focus-lock no longer exports class components. Maybe @saghul or @hristoterezov can take a look as well, since they've been around that block.

@muscat1 muscat1 force-pushed the muscat/dialog-focus branch from 757b340 to 460473c Compare May 17, 2021 12:38
@muscat1 muscat1 merged commit e33674f into jitsi:master May 18, 2021
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.

3 participants