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

Navigable regions: skip empty regions #63687

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function useNavigateRegions( shortcuts: Shortcuts = defaultShortcuts ) {
function focusRegion( offset: number ) {
const regions = Array.from(
ref.current?.querySelectorAll< HTMLElement >(
'[role="region"][tabindex="-1"]'
'[role="region"][tabindex="-1"]:not(:empty)'
Copy link
Member

Choose a reason for hiding this comment

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

Will do the job, although it's not perfect, since it :empty will be false if there's even just a whitespace character, like a space or a newline:

Children can be either element nodes or text (including whitespace)

Still, better than before 👍

Copy link
Member

Choose a reason for hiding this comment

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

I also wish we had some tests for this 🤔

Not a blocker for the PR of course.

Copy link
Member

Choose a reason for hiding this comment

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

Let's definitely include a CHANGELOG entry for this.

) ?? []
);
if ( ! regions.length ) {
Expand Down
Loading