Shopify / polaris

Shopify’s design system to help us work together to build a great experience for all of our merchants.
https://polaris.shopify.com
Other
5.82k stars 1.18k forks source link

[Autocomplete] Set selected options on text change #12916

Closed ryanaldred11 closed 1 week ago

ryanaldred11 commented 2 weeks ago

WHY are these changes introduced?

When the text changes to match or no longer match one of the Autocomplete options, the checkmark is not added or removed from the list item. This behaviour was called it in a PR review and it turned out to be the same behaviour that was copied from the Polaris documentation.

I didn't change the examples that allow you to select multiple options ('with multiple tags' and 'with lazy loading') because it doesn't feel like the right UX and you can use the enter button to select the option.

I made this change in admin-web and now I'm following up to update the Polaris documentation

WHAT is this pull request doing?

This PR adds functionality to the applicable Autocomplete examples in the Polaris documentation. Specifically the examples will now select and add the checkmark to the list item when you type in an exact match into the input. It also removes the selection and checked on text change if the new value is no longer an exact match or the entire string was removed.

How to 🎩

Before

https://github.com/user-attachments/assets/c9ea8fc5-ade4-4544-9f9a-97b4c05cc298

After

https://github.com/user-attachments/assets/65c3b2d8-9ddb-464e-99e1-fef5bf6b89dd

Examples

🖥 Local development instructions 🗒 General tophatting guidelines 📄 Changelog guidelines

🎩 checklist

ryanaldred11 commented 1 week ago

vetoed by polaris devs