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: Modal ocasionally not focusing properly making input unusable #34853

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

gabriellsh
Copy link
Member

@gabriellsh gabriellsh commented Dec 31, 2024

Proposed changes (including videos or screenshots)

Use inert prop instead of aria-hidden for disabling focus on document when a modal is open.

I was only able to notice this issue when trying to save an edited user in the admin page with TOTP enabled. The TOTP modal opens but the input is unaccessible with mouse clicks nor with keyboard navigation

Issue(s)

CORE-908

Steps to test or reproduce

Make sure TOTP is enable and Enforce password fallback is enabled aswell (usually both come enabled by default in new workspaces)

  • Go to Admin -> Users
  • Refresh the page (*1)
  • Select an user
  • Click edit and change any property
  • Click save
  • TOTP modal will open but unusable (only cancel or close buttons are clickable, but not accessible through keyboard)

Observations:
*1: By clicking "cancel" and trying again the issue goes away, so refreshing the page is necessary to reproduce the issue multiple times.
You can set Remember Two Factor for (seconds) to 0 in Admin -> Accounts -> Two Factor Authentication to ensure the TOTP modal appears every time, even if you successfully inputed the code/password.

Further comments

I do not know how this change affects screen readers, so some support here would be nice.

Edit: apparently inert should have the same effect as aria-hidden , and is supported in every major browser BESIDES IE11. See: https://caniuse.com/?search=inert

Copy link
Contributor

dionisio-bot bot commented Dec 31, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is targeting the wrong base branch. It should target 7.3.0, but it targets 7.2.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Dec 31, 2024

🦋 Changeset detected

Latest commit: 5249ab7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.36%. Comparing base (4460503) to head (5249ab7).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #34853   +/-   ##
========================================
  Coverage    59.36%   59.36%           
========================================
  Files         2819     2819           
  Lines        67652    67652           
  Branches     15022    15022           
========================================
  Hits         40159    40159           
  Misses       24678    24678           
  Partials      2815     2815           
Flag Coverage Δ
unit 75.85% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

PR Preview Action v1.4.8
🚀 Deployed preview to https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-34853/
on branch gh-pages at 2024-12-31 01:16 UTC

@gabriellsh gabriellsh marked this pull request as ready for review December 31, 2024 01:29
@gabriellsh gabriellsh requested a review from a team as a code owner December 31, 2024 01:29
@aleksandernsilva aleksandernsilva added this to the 7.3.0 milestone Dec 31, 2024
Copy link
Contributor

@aleksandernsilva aleksandernsilva left a comment

Choose a reason for hiding this comment

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

Tested, and the fix is working. Adding inert seems to help FocusScope sort itself out. Now, even though inert covers the aria-hidden functionality, Playwright seems to have some problems ignoring inert elements in the same way it does aria-hidden 🤔 .

Comment on lines +10 to +17
const inertBooleanSupported = Number(version.split('.')[0]) >= 19;

/**
* Before version 19, react JSX treats empty string "" as truthy for inert prop.
* @see {@link https://stackoverflow.com/questions/72720469}
* */
const isInert = inertBooleanSupported ? (x: boolean) => x : (x: boolean) => (x ? '' : undefined);

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this will need to be replicated to LayoutSidebarV2. It might be a good idea to have this as an util and use it in both files.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot that guy 😬

"@rocket.chat/meteor": patch
---

fixes an issue where opening a modal for the first times renders it's inputs unusable
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fixes an issue where opening a modal for the first times renders it's inputs unusable
Fixes an issue where opening a modal for the first times renders it's inputs unusable

@gabriellsh
Copy link
Member Author

Tested, and the fix is working. Adding inert seems to help FocusScope sort itself out. Now, even though inert covers the aria-hidden functionality, Playwright seems to have some problems ignoring inert elements in the same way it does aria-hidden 🤔 .

That's a good catch btw. I was wondering which problems we might face with this. I removed "aria-hidden" because aria was throwing errors and removing the prop in some cases. Maybe with both it should be fine...

Maybe there's another fix also since this didn't happen in every screen. I'll take a look

Copy link
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

I don't think ignoring the main layout elements is the proper fix, neither a good approach.
IMO we should investigate deeper the modal focus scope

PS: indeed we should remove aria-hidden, actually we've been receiving a warning regarding it

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.

4 participants