Skip to content

feat: focus loading indicator in rac tree #8270

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

Merged
merged 1 commit into from
May 27, 2025
Merged

feat: focus loading indicator in rac tree #8270

merged 1 commit into from
May 27, 2025

Conversation

yihuiliao
Copy link
Member

@yihuiliao yihuiliao commented May 20, 2025

Seems like the issue was that in the getKeyPageBelow method in ListKeyboardDelegate, this.layoutDelegate.getItemsRect(nextKey) was returning null when the nextKey was the loading indicator. When taking a closer look at the getItemRect method, we were early returning null from getItemElement since there wasn't [data-key] or [data-collection] on the loading indicator.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Should check the following things:

  1. The loading indicator is focusable
  2. PageUp/Down works
  3. ArrowDown brings the spinner into view

Use the RAC Tree stories

🧢 Your Project:

@rspbot
Copy link

rspbot commented May 20, 2025

@@ -1172,11 +1171,11 @@ describe('Tree', () => {
await user.tab();
expect(document.activeElement).toBe(rows[0]);
await user.keyboard('{PageDown}');
expect(document.activeElement).toBe(rows[20]);
expect(document.activeElement).toBe(rows[21]);

// Check that it didn't shift the focusedkey to the loader key even if DOM focus didn't shift to the loader
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

One thought I had, the spinner can disappear when new items are loaded, if the spinner is focused at that time, where does the focus go?

@yihuiliao
Copy link
Member Author

One thought I had, the spinner can disappear when new items are loaded, if the spinner is focused at that time, where does the focus go?

I think it should be handled here. That said, async loading isn't currently supported in Table but we can try to see how it works in GridList

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

LGTM, nice work figuring out the lack of data-collection on the loader. I'll pull this into the async tree loading branch I have to test the case where the loader disappears. Now that we have this working in tree (and by extension other components that use ListKeyboardDelegate), we'll want to propagate these changes to other collection components that support async, but that can be followup/separate ticket

@LFDanLu LFDanLu added this pull request to the merge queue May 27, 2025
Merged via the queue into main with commit ca2d897 May 27, 2025
31 checks passed
@LFDanLu LFDanLu deleted the tree-focus-loading branch May 27, 2025 17:10
@LFDanLu
Copy link
Member

LFDanLu commented May 27, 2025

just a heads up: tested in my PR for multi loader support and found some odd behavior where the focus seems to remain on the loader when loading is complete, but keyboard navigation no longer seems to work, digging into what might be happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants