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:
@ -11,16 +11,24 @@ export type CompanyPickerProps = {
|
||||
companyId: string | null;
|
||||
onSubmit: (newCompanyId: EntityForSelect | null) => void;
|
||||
onCancel?: () => void;
|
||||
initialSearchFilter?: string | null;
|
||||
};
|
||||
|
||||
export const CompanyPicker = ({
|
||||
companyId,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
initialSearchFilter,
|
||||
}: CompanyPickerProps) => {
|
||||
const [relationPickerSearchFilter, setRelationPickerSearchFilter] =
|
||||
useRecoilScopedState(relationPickerSearchFilterScopedState);
|
||||
|
||||
useEffect(() => {
|
||||
if (initialSearchFilter) {
|
||||
setRelationPickerSearchFilter(initialSearchFilter);
|
||||
}
|
||||
}, [initialSearchFilter, setRelationPickerSearchFilter]);
|
||||
|
||||
const companies = useFilteredSearchCompanyQuery({
|
||||
searchFilter: relationPickerSearchFilter,
|
||||
selectedIds: companyId ? [companyId] : [],
|
||||
@ -32,10 +40,6 @@ export const CompanyPicker = ({
|
||||
onSubmit(selectedCompany ?? null);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setRelationPickerSearchFilter('');
|
||||
}, [setRelationPickerSearchFilter]);
|
||||
|
||||
return (
|
||||
<SingleEntitySelect
|
||||
entitiesToSelect={companies.entitiesToSelect}
|
||||
|
||||
Reference in New Issue
Block a user