You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a CreateableSelect and realized that the default search/filtering looks at both label and value. I found filterOption in the docs and figured I could create a filter on the stringify parameter, which I did as follows:
This works as expected - it no longer filters on option value, just label. However if there is an option value that would have matched, the option to 'Create' disappears. For example, my values are numerical ids. I have an option that has the id and value 26. If I type 26 into the search, it just says 'No options' but if I type 25 or 27, I am shown the option to 'Create "25"'.
Am I doing something incorrect with the filtering?
Edit:
I just noticed that if I type something that substring matches the label of one of the options that is also the id of another option, this shows the matching option by label, but it also loses the 'Create' in that setting and only shows the existing option. If I type something that substring matches the label of another option but doesn't match the id of any options, then it does show 'Create' as one of the options.
It seems like anytime there is an exist match for an option value using this filterOption that the ability to create is lost.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using a
CreateableSelect
and realized that the default search/filtering looks at both label and value. I foundfilterOption
in the docs and figured I could create a filter on thestringify
parameter, which I did as follows:This works as expected - it no longer filters on option value, just label. However if there is an option value that would have matched, the option to 'Create' disappears. For example, my values are numerical ids. I have an option that has the id and value 26. If I type 26 into the search, it just says 'No options' but if I type 25 or 27, I am shown the option to 'Create "25"'.
Am I doing something incorrect with the filtering?
Edit:
I just noticed that if I type something that substring matches the label of one of the options that is also the id of another option, this shows the matching option by label, but it also loses the 'Create' in that setting and only shows the existing option. If I type something that substring matches the label of another option but doesn't match the id of any options, then it does show 'Create' as one of the options.
It seems like anytime there is an exist match for an option value using this
filterOption
that the ability to create is lost.Beta Was this translation helpful? Give feedback.
All reactions