-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add searchable select #339
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial thoughts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how the store-based solution for unique IDs works, but I don't love how it requires to add an extra context provider to use the some components in the library. Given that this implementation is not SSR stable, would it be better to simply go with nanoid/non-secure
and forgo adding in a required context?
We could also just have it track the count internally without a store, but then we will need to require it be imported via a I am cool with just using |
a45cbe4
to
d5afeca
Compare
a81eee4
to
75c4d67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider using userEvent
for this testing to simulate interactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed we hadn't migrated elsewhere and @testing-library/svelte
does not include userEvent
. If we want to move to that, I would rather have a follow-up ticket to apply it in all of our tests instead of having a mix of solutions.
0: SearchMatch[]; | ||
'-1': SearchMatch[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these necessary given L59?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input: string | undefined; | ||
change: string | undefined; | ||
search: string; | ||
buttonclick: undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intention of an undefined event value? If undefined is meant to mean "empty", could this be typed as null
? Or maybe an explicitly typed object would be most clear to the consumer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It signals the event does not include any data, essentially a () => void
handler. We just want to signal when the button has been clicked, we make no other assumptions about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the cases that I've wanted this, I've explicitly typed the return as Record<string, never>
to signal to the consumer the lack of associated detail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read through a bunch on this and landed on this PR where the feature was added, specifically this comment: sveltejs/svelte#7224 (comment)
Also with this, we signal to the user the detail is undefined
:
If I use Record<string, never>
this is what we show the user, which is way less clear IMO:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though looking at the migration docs for v4
it seems null
is preferred so we can swap to that. Generally I prefer undefined
but I don't mind sticking to their recommendation: https://svelte.dev/docs/v4-migration-guide#stricter-types-for-svelte-functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, agree with Ethan's comments
e7237b9
to
ab067cc
Compare
ab067cc
to
26a5a56
Compare
Adds a searchable version of the select using an input and a custom menu:
Also includes a bundle of small fixes and adjustments that came up during review/testing.