Command palette - not fuzzy search? #126
-
Command palette is not a fuzzy search ![]()
![]()
![]() I expected this to be a fuzzy search, clearly it is not, bug or a feature? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 14 replies
-
@danielrona thanks for reporting! At this stage it's not a bug as such, but we do agree that it probably should be supported. I have converted this to a feature request instead. |
Beta Was this translation helpful? Give feedback.
-
Just piggy-backing off of this too. Ideally if we could pass in a closure as well that would be 👌 Thanks for your work on Flux! |
Beta Was this translation helpful? Give feedback.
-
+1. This also applies to other components like searchable selects or autocomplete. <flux:autocomplete fuzzy> |
Beta Was this translation helpful? Give feedback.
-
I agree too. |
Beta Was this translation helpful? Give feedback.
-
I think relying on While it ensures an exact match at the beginning of the string, it doesn't account for scenarios where users may expect a match anywhere in the string. For example, searching for "app" in "pineapple" won't return a match, which might feel unintuitive to users. Switching to If fuzzy search is too much to implement for now,
to
|
Beta Was this translation helpful? Give feedback.
-
As a work around for now, you can currently implement fuzzy search on the backend but turning off frontend filtering by passing public $search;
#[Computed]
public function commands()
{
$commands = collect([
'Assign to…',
'Create new file',
'Create new project',
'Documentation',
'Changelog',
'Settings',
]);
return $commands->filter(function ($command) {
return str_contains(strtolower($command), strtolower($this->search));
});
} <flux:command :filter="false">
<flux:command.input wire:model.live="search" placeholder="Search..." />
<flux:command.items>
@foreach ($this->commands as $command)
<flux:command.item wire:click="..." icon="user-plus">{{ $command }}</flux:command.item>
@endforeach
</flux:command.items>
</flux:command> |
Beta Was this translation helpful? Give feedback.
-
Ok, I'm going with @beneyraheem's suggestion for now. Using We can keep the discussion going about more fuzzy options, but I think this is a better default and solves most people's needs (for example, this is select2's default behavior). Thanks for bringing this to my attention and suggesting such a simple solution. I might have overcomplicated this otherwise. |
Beta Was this translation helpful? Give feedback.
-
Someone commented that this is not a bug, but https://fluxui.dev/components/select#searchable-select does fuzzy search. I'm a bit confused. How can the select on documentation work correctly, but not the package itself? Try inputting "dev" in search box on the documentation to see what I mean. |
Beta Was this translation helpful? Give feedback.
Btw, here is my dream algo as the default:
However, because we are just filtering DOM elements in-place and not rendering them based on a dataset, anything that changes the order of the search results will have to be done in developerland using Alpine or Livewire. Super bummer, but whatever,
.includes
is good enough.