Skip to content

Improve keyboard accessibility#371

Draft
flakey5 wants to merge 3 commits into
alveusgg:mainfrom
flakey5:flakey5/139
Draft

Improve keyboard accessibility#371
flakey5 wants to merge 3 commits into
alveusgg:mainfrom
flakey5:flakey5/139

Conversation

@flakey5
Copy link
Copy Markdown
Contributor

@flakey5 flakey5 commented Oct 2, 2025

Closes #139

  • Allows for closing active overlays/ambassador cards with escape
  • Better experience navigating with tab
    • Auto focus overlays/ambassador cards when opened
    • Adding/removing tab indexes for what should & shouldn't be focusable w/ tab
  • Don't sleep when an element in the overlay is focused

@flakey5 flakey5 requested a review from a team as a code owner October 2, 2025 20:05
activeOverlayRef.current = node;

// Auto focus the overlay that's currently selected
node?.focus();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This part doesn't seem to be working and I can't really tell why?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this meant to do that it isn't doing? Focus the entire active overlay (e.g. the entire ambassadors list)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's supposed to focus the active overlay that was just opened like how it does when setting the active ambassador

Copy link
Copy Markdown
Member

@MattIPv4 MattIPv4 Nov 6, 2025

Choose a reason for hiding this comment

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

src/pages/overlay/components/overlay/Ambassadors.tsx doesn't take a ref, and doesn't have a tabIndex, so that might be why?

(nor does src/pages/overlay/components/overlay/Settings.tsx, and src/components/Welcome.tsx has a ref but not tabIndex)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The root element in Ambassadors.tsx doesn't take in a ref, but the parent element of the AmbassadorButton does and that's what it's trying to focus

Interestingly adding a setTimeout around the node?.focus() does cause the element to be focused properly, so I think it's something similar to https://stackoverflow.com/a/76033876 where it's just not triggering a re-render

@MattIPv4
Copy link
Copy Markdown
Member

Sorry for the delay on getting to this @flakey5, been pretty busy with some upcoming secret bits for Alveus. Any chance you could rebase this?

Copy link
Copy Markdown
Member

@MattIPv4 MattIPv4 left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long to get to this

Comment thread src/utils/keyBinds.ts
Comment thread src/pages/overlay/App.tsx Outdated
Comment thread src/pages/overlay/components/overlay/Ambassadors.tsx Outdated
activeOverlayRef.current = node;

// Auto focus the overlay that's currently selected
node?.focus();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this meant to do that it isn't doing? Focus the entire active overlay (e.g. the entire ambassadors list)?

Comment thread src/pages/overlay/components/overlay/Overlay.tsx Outdated
Comment thread src/pages/overlay/hooks/useSleeping.tsx Outdated
Comment thread src/pages/overlay/hooks/useSleeping.tsx Outdated
Comment thread src/pages/overlay/hooks/useSleeping.tsx
Comment thread src/pages/overlay/hooks/useSleeping.tsx Outdated
@flakey5
Copy link
Copy Markdown
Contributor Author

flakey5 commented Nov 4, 2025

Sorry for taking so long to get to this

No worries at all!

Addressed some of the review comments in latest commit, trying to see if there's a better way to detect when we should pause the sleeping timer though.

Right now when we detect that we're focusing the app it also detects when we focus on child elements, so every time we tab to different overlays, ambassadors, etc. the event fires and calls caffeinate and the same happens with onBlur/uncaffeinate. I feel like ideally we can just detect when we app is focused/unfocused, but I'm not fully familiar with front end stuff to know if there's an actual good way to do that, wdyt?

@MattIPv4
Copy link
Copy Markdown
Member

MattIPv4 commented Nov 6, 2025

Yeh, I think my concern is that the focus event can be fired by things other than keyboard navigation -- clicking on a button or really anything with a tab index will generally cause it to become focused, I think?

Closes alveusgg#139

Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
@flakey5 flakey5 marked this pull request as draft January 19, 2026 01:37
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
@flakey5
Copy link
Copy Markdown
Contributor Author

flakey5 commented Jan 19, 2026

Apologizes for the delay on this - moving this back into the draft state for now.

Current todos:

  • Figure out why focusing overlays isn't triggering a rerender
  • caffeinate causes rerender in Overlay.tsx which means it dumps then reestablishes the connection to Twitch chat
  • uncaffeinate and wake called when exiting ambassador card back to ambassador list

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.

Make extension keyboard accessible

2 participants