Skip to content

Fixing fully controlled combobox aria example #1576

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 2 commits into from
Feb 16, 2021

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Feb 12, 2021

Closes

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

@@ -499,7 +497,7 @@ function ControlledComboBox() {
isOpen: true,
inputValue: value,
selectedKey: value === '' ? null : prevState.selectedKey,
items: filteredItems
items: optionList.filter(item => startsWith(item.name, value))
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 was broken because the memoized filteredItems is one step behind the user input (aka the latest input value is set after this setState but the items set here were based on the previous input value). This should fix

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@devongovett
Copy link
Member

devongovett commented Feb 16, 2021

One more issue I noticed: type something invalid and click outside. The field is cleared, but the menu also opens. Same bug also appears to occur in the Spectrum docs example.

@LFDanLu
Copy link
Member Author

LFDanLu commented Feb 16, 2021

@devongovett Hrm, seems to be due to onInputChange firing after the the triggerState.close but only for this specific case, not sure why...
Possible solution would be to call props.onOpenChange(false) after that line but that feels a bit wrong, still digigng

@devongovett
Copy link
Member

Should onInputChange not set isOpen to true when the value is empty?

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Merging. We will address the above issue in a followup post release.

@devongovett devongovett merged commit 6d23997 into main Feb 16, 2021
@devongovett devongovett deleted the aria-combobox-example-fix branch February 16, 2021 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants