441/fix/clear cell while opening it by typing and delete value when I hit delete / backspace. (#2021)

- Use initial values when opening table cells and pass them to fields

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Abhishek Thory
2023-11-03 21:13:54 +05:30
committed by GitHub
parent 60b1024efb
commit c397619100
39 changed files with 339 additions and 70 deletions

View File

@ -1,3 +1,5 @@
import { useEffect } from 'react';
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
import { IconUserCircle } from '@/ui/display/icon';
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
@ -12,6 +14,7 @@ export type UserPickerProps = {
onSubmit: (newUser: EntityForSelect | null) => void;
onCancel?: () => void;
width?: number;
initialSearchFilter?: string | null;
};
type UserForSelect = EntityForSelect & {
@ -23,10 +26,14 @@ export const UserPicker = ({
onSubmit,
onCancel,
width,
initialSearchFilter,
}: UserPickerProps) => {
const [relationPickerSearchFilter] = useRecoilScopedState(
relationPickerSearchFilterScopedState,
);
const [relationPickerSearchFilter, setRelationPickerSearchFilter] =
useRecoilScopedState(relationPickerSearchFilterScopedState);
useEffect(() => {
setRelationPickerSearchFilter(initialSearchFilter ?? '');
}, [initialSearchFilter, setRelationPickerSearchFilter]);
const users = useFilteredSearchEntityQuery({
queryHook: useSearchUserQuery,