mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:25:22 +02:00
Implement Enter key support for quick filtering
This commit is contained in:
@@ -155,6 +155,23 @@ const MultiSelectDropdown: React.FC<MultiSelectDropdownProps> = ({ label, select
|
||||
className="w-full bg-slate-950 border border-slate-700 text-slate-200 text-sm rounded-md py-1.5 pl-9 pr-2 focus:outline-none focus:border-primary"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
if (filteredOptions.length > 0) {
|
||||
const allSelected = filteredOptions.every(opt => selected.includes(opt));
|
||||
if (allSelected) {
|
||||
// Deselect all filtered
|
||||
onChange(selected.filter(item => !filteredOptions.includes(item)));
|
||||
} else {
|
||||
// Select all filtered
|
||||
onChange(Array.from(new Set([...selected, ...filteredOptions])));
|
||||
}
|
||||
setIsOpen(false);
|
||||
setSearchTerm('');
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user