Comments (1)
Try-and-error many times and I found it's related to cmdk
.
You can provide a filter in Command
and the creatable selector won't freeze.
return (
<Command
{...commandProps}
onKeyDown={(e) => {
handleKeyDown(e);
commandProps?.onKeyDown?.(e);
}}
className={cn('overflow-visible bg-transparent', commandProps?.className)}
shouldFilter={
commandProps?.shouldFilter !== undefined ? commandProps.shouldFilter : !onSearch
} // When onSearch is provided, we don't want to filter the options. You can still override it.
+ filter={(value, search) => {
+ return value.toLowerCase().includes(search.toLowerCase()) ? 1 : -1;
+ }}
>
here is a fixed version if you want to fix it yourself.
or an easy way to fix it without modifying multipleSelector.tsx
by giving prop:
const MultipleSelectorCreatable = () => {
return (
<div className="w-full px-10">
<MultipleSelector
defaultOptions={OPTIONS}
placeholder="Type something that does not exist in dropdowns..."
creatable
emptyIndicator={
<p className="text-center text-lg leading-10 text-gray-600 dark:text-gray-400">
no results found.
</p>
}
+ commandProps={{
+ filter: (value, search) => {
+ return value.toLowerCase().includes(search.toLowerCase()) ? 1 : -1; // write your own filtering logic.
+ },
+ }}
/>
</div>
);
};
An known issue:
The filtering logic value.toLowerCase().includes(search.toLowerCase()) ? 1 : -1;
will cause CreatableItem
disappear when typing a space
in the end. For example: Hello
, a space in the end and the CreatableItem
disappeared.
but Hello my friend
works fine.
Because the value
in cmdk
is trim()
so that they won't match.
![image](https://private-user-images.githubusercontent.com/21173302/301572810-252726d8-9dd6-4204-959f-b75b7c16e53e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1NTQwNDksIm5iZiI6MTcxODU1Mzc0OSwicGF0aCI6Ii8yMTE3MzMwMi8zMDE1NzI4MTAtMjUyNzI2ZDgtOWRkNi00MjA0LTk1OWYtYjc1YjdjMTZlNTNlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQ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mWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.R5HKdVvGdwvARPm1YYVtHoIjNmalp6ewKMSvrVQMQJ0)
from shadcn-ui-expansions.
Related Issues (20)
- Using TimePicker only on form HOT 1
- Existing size option not applied when using Loading Button HOT 3
- Missing license - may not be used for commercial purposes HOT 4
- Popover content doesn't show up when used inside accordion. HOT 6
- AutosizeTextarea doesn't resize with defaultValue. HOT 1
- elm.focus is not a function HOT 8
- [ Async Search with Debounce and Creatable ] is always in the loading state HOT 1
- Multiple selector does not work inside a conditional modal component HOT 1
- Multiple Selector collapsible groups HOT 1
- Controlled Datetime Picker's calendar doesn't correctly set start state value HOT 2
- Pressing 'Enter' on another form input focuses multi-selector HOT 1
- Multi Selector slowing down when options are too large HOT 1
- Multiselect fixed options can be removed by backspace or delete key. HOT 1
- Issue with Creatable Multi-Selector Box Not Creating First Item HOT 3
- Unhandled Runtime Error with Autofill on Multi-Selector HOT 6
- InfiniteScroll Warning: Function components cannot be given refs. HOT 1
- [bug]: date-time picker closing works partially HOT 1
- Multiselect Clear all button HOT 1
- How to set minValue for the date picker component HOT 1
- [bug]: Text Area resizing after setting the value to '' on Chrome HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shadcn-ui-expansions.