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

fix: [BUG] - Autocomplete - Text selection with Shift + Home/End isn't working (#7228) #7403

Open
wants to merge 1 commit into
base: main
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
6 changes: 6 additions & 0 deletions packages/@react-aria/selection/src/useSelectableCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
}
case 'Home':
if (delegate.getFirstKey) {
if (manager.focusedKey === null && e.shiftKey) {
return;
}
Comment on lines 224 to +227
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 this is fine, but I wonder if we should make it consistent with PageUp/Down where Home/End returns early if the focusedKey is null (or if PageUp/Down should be changed so they move focus into the collection even if a focusedKey doesn't exist). Also, I remember that you mentioned noticing an inconsistency between RAC and RSP combobox or something? Mind reminding me what that was?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not noticing the inconsistency between RAC and RSP for this behavior using the current builds for this PR now, but perhaps it's because I've gotten used to a particular way of testing.

Regarding PageUp/PageDown, I'm not sure that adding this code will change anything in the behavior when there is no focusedKey, because, with no focusedKey, PageUp/PageDown currently doesn't seem to do anything.

It may make sense for PageUp/PageDown to move focus into the collection as you suggest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also spent some time yesterday seeing if I could change the behavior of the Escape key so that it does not clear the input if the user wants to close the input before editing their search.

e.preventDefault();
let firstKey: Key | null = delegate.getFirstKey(manager.focusedKey, isCtrlKeyPressed(e));
manager.setFocusedKey(firstKey);
Expand All @@ -236,6 +239,9 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
break;
case 'End':
if (delegate.getLastKey) {
if (manager.focusedKey === null && e.shiftKey) {
return;
}
e.preventDefault();
let lastKey = delegate.getLastKey(manager.focusedKey, isCtrlKeyPressed(e));
manager.setFocusedKey(lastKey);
Expand Down