Implement Enter key support for quick filtering

This commit is contained in:
christian.vidal
2026-01-29 20:59:35 +01:00
parent 9200c554e1
commit b1c3897cfd
+17
View File
@@ -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>