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

Autosuggest: use something other than state.dropDownItems.length > 0 to filter document clicks #2510

Closed
brian-smith-tcril opened this issue Aug 8, 2023 · 2 comments · Fixed by #2517
Assignees
Labels
bug Report of or fix for something that isn't working as intended released on @alpha released

Comments

@brian-smith-tcril
Copy link
Contributor

In #1732 I noticed

there is also no error message if text is entered that doesn't match anything in the dropdown (for example, typing "foo" in any of the sample boxes)

it seems this is happening because we have state.dropDownItems.length > 0 in

if (parentRef.current && !parentRef.current.contains(e.target) && state.dropDownItems.length > 0) {

where we are handling all clicks on the document

if we remove state.dropDownItems.length > 0 and instead just have

if (parentRef.current && !parentRef.current.contains(e.target)) {

interacting with any autosuggest component on the docs page causes error states in the others

I believe the intention here is to not set the error state on components other than the one the user is interacting with. This implies that state.dropDownItems.length > 0 is being used to mean "this is the autosuggest component the user is interacting with right now."

In the case where we have entered text that filters the dropdownitems down to a length of zero, the component behaves as if it is not the one the user is interacting with, and doesn't show an error.

We should not rely on state.dropDownItems.length > 0 to mean "this is the autosuggest component the user is interacting with right now," as it is possible to filter the dropDownItems down to a length of zero while interacting with the component.

@edx-semantic-release
Copy link
Contributor

🎉 This issue has been resolved in version 21.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@edx-semantic-release
Copy link
Contributor

🎉 This issue has been resolved in version 22.0.0-alpha.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report of or fix for something that isn't working as intended released on @alpha released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants