Skip to content

feat: support selectionMode="replace" in grid collection test utils #8028

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Apr 2, 2025

Closes #7884

✅ 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:

🧢 Your Project:

@LFDanLu LFDanLu changed the base branch from main to test_util_bug_fixes April 2, 2025 22:31
@rspbot
Copy link

rspbot commented Apr 3, 2025

@LFDanLu LFDanLu changed the title feat: (WIP) enhance selectionMode="replace" support in grid collection test utils feat: support selectionMode="replace" in grid collection test utils Apr 3, 2025
Comment on lines +107 to +108
// TODO: perhaps this should just be shouldUseModifierKeys?
selectionBehavior = 'toggle'
Copy link
Member Author

Choose a reason for hiding this comment

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

This API naming feels unclear TBH, people may be confused as to when they would apply it. When set to selectionBehavior="replace" this causes the alt/meta key to be used when keyboard navigating/pressing to select a row so that it doesn't cause your previous selection to be replaced on focus/click. I wasn't certain if something like shouldUseModifierKeys was clear either since a user may not know what the "modifier keys" even do

Copy link
Member

Choose a reason for hiding this comment

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

I think selectionBehavior is fine or gridListSelectionBehavior if you want to be clear it should match, then the user profiles/interactions should handle most things behind the scenes

@LFDanLu LFDanLu marked this pull request as ready for review April 8, 2025 17:05
Base automatically changed from test_util_bug_fixes to main April 8, 2025 21:31
@rspbot
Copy link

rspbot commented Apr 14, 2025

@@ -22,6 +22,7 @@
"url": "https://github.com/adobe/react-spectrum"
},
"dependencies": {
"@react-aria/utils": "^3.28.1",
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should have a dependency going in this direction, test-utils should never depend on our actual packages
too easy to make a circular dependency

import {UserOpts} from './types';

export const DEFAULT_LONG_PRESS_TIME = 500;
export function getAltKey(): 'Alt' | 'ControlLeft' {
Copy link
Member

Choose a reason for hiding this comment

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

? what does isMac return in a test environment?
I feel like we should hook this into the user config if we need it

Comment on lines +107 to +108
// TODO: perhaps this should just be shouldUseModifierKeys?
selectionBehavior = 'toggle'
Copy link
Member

Choose a reason for hiding this comment

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

I think selectionBehavior is fine or gridListSelectionBehavior if you want to be clear it should match, then the user profiles/interactions should handle most things behind the scenes

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.

Update Tree/Table/etc test utils to handle selectionBehavior="replace"
3 participants