Remove debounce on filter search bar (#5215)

A search bar has been introduced in the filter dropdown menu however we
don't want to apply debounce since the search has no side-effect and is
purely FE (it's not querying the DB compared to other search bars). Also
adding autofocus on the search bar when the dropdown is open.
This commit is contained in:
Weiko
2024-04-30 10:44:32 +02:00
committed by GitHub
parent fab385179b
commit 95d80af0c6

View File

@ -2,7 +2,6 @@ import { useState } from 'react';
import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil';
import { useIcons } from 'twenty-ui';
import { useDebouncedCallback } from 'use-debounce';
import { useFilterDropdown } from '@/object-record/object-filter-dropdown/hooks/useFilterDropdown';
import { RelationPickerHotkeyScope } from '@/object-record/relation-picker/types/RelationPickerHotkeyScope';
@ -55,19 +54,15 @@ export const ObjectFilterDropdownFilterSelect = () => {
const setHotkeyScope = useSetHotkeyScope();
const debouncedSetSearchFilter = useDebouncedCallback(setSearchText, 100, {
leading: true,
});
const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
debouncedSetSearchFilter(event.target.value);
};
return (
<>
<StyledInput
value={searchText}
autoFocus
placeholder="Search fields"
onChange={handleSearchChange}
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
setSearchText(event.target.value)
}
/>
<DropdownMenuItemsContainer>
{[...availableFilterDefinitions]