Skip to content

Fix combobox issue handling tab/enter custom value is allowed #2670

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 12 commits into from
Jul 31, 2023

Conversation

BDesta
Copy link
Contributor

@BDesta BDesta commented Dec 9, 2021

  • Share logic so that tab/enter on combobx share same behaviour as when
    isFocused is false which is working as expected

Closes #2413, #4728

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

Adobe

* Share logic so that tab/enter on combobx share same behaviour as when
  isFocused is false which is working as expected
LFDanLu
LFDanLu previously approved these changes Dec 10, 2021
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, thanks for adding the tests! Left a comment for the team to note a change in behavior which I feel is more correct

Comment on lines +1586 to +1602
it('retains selected key on enter', function () {
let {getByRole} = renderComboBox({allowsCustomValue: true, selectedKey: '2'});

let combobox = getByRole('combobox');
act(() => {
userEvent.click(combobox);
jest.runAllTimers();
});

act(() => {
fireEvent.keyDown(combobox, {key: 'Enter', code: 13, charCode: 13});
fireEvent.keyUp(combobox, {key: 'Enter', code: 13, charCode: 13});
jest.runAllTimers();
});

expect(onSelectionChange).not.toHaveBeenCalled();
});
Copy link
Member

Choose a reason for hiding this comment

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

This is a change from prior behavior, but I think this new behavior is more correct.
Previous behavior:

  1. User selects an option from the dropdown.
  2. User hits enter on the field
  3. onSelectionChange is fired with null to remove the selected key since we figured the user was committing a custom value

New behavior

  1. User selects an option from the dropdown.
  2. User hits enter on the field
  3. Previous selection is not removed since the text matches the selected key text

I figure the scenario of a user selecting a option and then immediately hitting enter to submit it as a custom value doesn't really happen.

@ktabors
Copy link
Member

ktabors commented Jun 14, 2023

GET_BUILD

ktabors
ktabors previously approved these changes Jun 14, 2023
@ktabors ktabors dismissed stale reviews from LFDanLu and themself via 9039c26 June 14, 2023 22:07
@garand
Copy link

garand commented Jun 28, 2023

What would it take to get this merged? Happy to help.

LFDanLu added 2 commits June 28, 2023 17:03
close shouldnt always commit the focused value (e.g when clicking to blur) so changing it back to commitValue. We should revist the commit and close logic to clean it up and clarify when to commit and when not to.
@LFDanLu
Copy link
Member

LFDanLu commented Jun 29, 2023

@garand I've pushed up a fix to the logic that should unblock this PR.

@LFDanLu
Copy link
Member

LFDanLu commented Jun 29, 2023

GET_BUILD

@rspbot
Copy link

rspbot commented Jun 29, 2023

@reidbarber
Copy link
Member

GET_BUILD

@rspbot
Copy link

rspbot commented Jul 31, 2023

@rspbot
Copy link

rspbot commented Jul 31, 2023

## API Changes

unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }

Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

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

LGTM

@reidbarber reidbarber merged commit 1725d70 into adobe:main Jul 31, 2023
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.

leaving fully controlled ComboBox (with allowsCustomValue) by Tab/Enter clears selection
6 participants