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

LG-13363: Fix Screenreader Focus Jumping During Selfie Capture #10668

Merged

Conversation

charleyf
Copy link
Contributor

@charleyf charleyf commented May 21, 2024

🎫 Ticket

Link to the relevant ticket:
https://cm-jira.usa.gov/browse/LG-13363

🛠 Summary of changes

Fix a problem where when using a screenreader focus would jump away from the capture button in selfie capture. Slack thread here.

📜 Testing Plan

  • Make sure you can reproduce the problem

    • Check out main
    • Log in
    • Get to front/back/selfie page
    • Turn on screenreader (iOS/chrome)
    • Open the selfie capture
    • Dismiss the camera permissions prompt (or allow)
    • Tap near or on the red capture button
    • Instead of focusing that button the focus of the screenreader jumps to the hidden close button in the top right.
  • Check that the problem is fixed by this PR

    • Check out this branch.
    • Do the above steps again.
    • When you click the near the red button, focus will jump to to the red button. Clicking on the red button will also focus it correctly.

@@ -21,6 +21,12 @@ function AcuantSelfieCaptureCanvas({ imageCaptureText, onSelfieCaptureClosed })
// The Acuant SDK script AcuantPassiveLiveness attaches to whatever element has
// this id. It then uses that element as the root for the full screen selfie capture
const acuantCaptureContainerId = 'acuant-face-capture-container';

const elementInShadow = document
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Look for the camera container to see if Acuant has actually loaded their stuff onto the screen. Obviously inelegant, but does the job.

Copy link
Member

Choose a reason for hiding this comment

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

How does this update if Acuant becomes loaded? Are we expecting it to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's what I think is happening:

  1. <AcuantSelfieCamera> is created, and Acuant is "started", but crucially the capture window doesn't appear anywhere yet.
  2. <FullScreen> activates a focus trap around <AcuantSelfieCaptureCanvas>.
  3. At this moment there's nothing inside that focus trap except a button and a div because Acuant hasn't actually attached to the div with acuantCaptureContainerId.
  4. Then, Acuant attaches to the div with acuantCaptureContainerId and hydrates in their Shadow DOM.

The problem that this PR solves is that it lets me show the button on Step 3, and hide it on Step 4. Practically, what happens if you try to fully remove the button is you get an error about the FocusTrap always needing a tabbable element (which makes sense).

  • So that close button needs to be present until the moment that Acuant's Shadow DOM gets attached.
  • Having that button seems to be the cause of some odd behavior when using a screenreader so it's worthwhile to remove it.

Copy link
Member

Choose a reason for hiding this comment

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

The primary concern I have here is that I don't see where we predictably expect React to re-render this component after the changes you describe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A good point, the re-render isn't necessarily tied to this code in the way I want. We do re-render the AcuantSelfieCaptureCanvas every time the help text changes (frequently) so this value does get updated.

@charleyf charleyf marked this pull request as ready for review May 21, 2024 19:07
@charleyf charleyf requested a review from amirbey May 21, 2024 19:07
@charleyf charleyf changed the title Charley/fix focus issue with selfie capture red green button LG-13363: Fix Screenreader Focus Jumping During Selfie Capture May 21, 2024
Copy link
Contributor

@amirbey amirbey left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏿

Thanks @charleyf

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Can we add test coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RE: Test coverage @aduth. Unfortunately, we still do not have a way to actually get the Acuant SDK to start under any sort of testing conditions. It's a hole we've been aware of for a while, but it's pretty difficult to address.

Copy link
Member

Choose a reason for hiding this comment

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

I only see code which expects a DOM element with a particular ID, and a state updater. I don't know that we need a full Acuant installation loaded to be able to test against that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test, which I think does a fairly good job showing how this functionality works.

@charleyf charleyf merged commit 9f9c910 into main May 22, 2024
2 checks passed
@charleyf charleyf deleted the charley/fix-focus-issue-with-selfie-capture-red-green-button branch May 22, 2024 18:21
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