Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ComboboxControl: Convert to TypeScript #47581
ComboboxControl: Convert to TypeScript #47581
Changes from 9 commits
eef24a2
7b22327
0c0ff12
2760042
00f8854
22e5f4d
bb17a6a
ae5eb6a
497e33f
98b6471
8241d6d
0365ccb
5659821
ca5b3b2
550db09
d75b49a
9d39fbc
91bc89a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
(Not something strictly for this PR, more of a general reflection to be discussed and prioritised separately)
We should take a look at the type signature of
onChange
functions across the package. In particular:onChange
has the same type as thevalue
prop of the componentonChange
withnull
as a the argument ? Orundefined
? I believe that for some components, theonChange
callback may not be fired at all in similar scenariosTokenInputProps['onChange']
passes en object with thevalue
prop, instead of the value directlyWhat are your thoughts? We could probably open a separate issue to track this.
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 have a feeling we won't be able to actually standardize the APIs for our existing components (because back compat). The only thing we can do is agree on a standard moving forward for new components.
Yes 💯
This will likely not be a concern for new components, since we're moving away from built in reset buttons. If it does arise though, I still think calling
onChange( undefined )
is the most straightforward and "standardizable" way. This is an overview of the current built-in reset behavior by the way:undefined
Record< string, undefined >
)null
empty string
empty array
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.
Yeah, I have the same suspicion. But as you say, we can at least enforce a standard for future work
This recap is already so valuable, thank you!
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.
This definitely works with the initial value undefined, as seen in the readme code snippet and in unit tests.
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.
Interesting to see how
null
is being used here, in the context of #47473There 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.
Exactly, it might even be the first one I've seen with an explicit
null
🤔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.
Typesafe helper function to explicitly handle the case when
selectedSuggestion
is null. Should not change runtime behavior, asArray.indexOf()
will return-1
when there is no match.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.
Removed this
tabIndex
because it isn't a valid prop on BaseControl and doesn't do anything.