-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify multi-object picker logic with search (#8010)
Simplifying the logic around multi-object pickers and search by getting rid of the behaviour that keeped selected elements even when they did not match the search filter (eg keeping selected record "Brian Chesky" in dropdown even when search input is "Qonto"). This allows us to simplify the fetch queries around the search to only do one query. --------- Co-authored-by: Lucas Bordeau <[email protected]>
- Loading branch information
1 parent
2ab4aa1
commit ac233b7
Showing
16 changed files
with
214 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../modules/object-record/record-field/states/objectRecordMultiSelectComponentFamilyState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ecord/record-field/states/objectRecordMultiSelectMatchesFilterRecordsIdsComponentState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ObjectRecordForSelect } from '@/object-record/types/ObjectRecordForSelect'; | ||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState'; | ||
|
||
export const objectRecordMultiSelectMatchesFilterRecordsIdsComponentState = | ||
createComponentState<ObjectRecordForSelect[]>({ | ||
key: 'objectRecordMultiSelectMatchesFilterRecordsIdsComponentState', | ||
defaultValue: [], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...tion-picker/components/ActivityTargetInlineCellEditModeMultiRecordsSearchFilterEffect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useEffect } from 'react'; | ||
import { useRecoilValue, useSetRecoilState } from 'recoil'; | ||
|
||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
import { objectRecordMultiSelectMatchesFilterRecordsIdsComponentState } from '@/object-record/record-field/states/objectRecordMultiSelectMatchesFilterRecordsIdsComponentState'; | ||
import { useRelationPickerScopedStates } from '@/object-record/relation-picker/hooks/internal/useRelationPickerScopedStates'; | ||
import { useMultiObjectSearchMatchesSearchFilterQuery } from '@/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterQuery'; | ||
import { RelationPickerScopeInternalContext } from '@/object-record/relation-picker/scopes/scope-internal-context/RelationPickerScopeInternalContext'; | ||
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; | ||
|
||
export const ActivityTargetInlineCellEditModeMultiRecordsSearchFilterEffect = | ||
() => { | ||
const scopeId = useAvailableScopeIdOrThrow( | ||
RelationPickerScopeInternalContext, | ||
); | ||
|
||
const setRecordMultiSelectMatchesFilterRecords = useSetRecoilState( | ||
objectRecordMultiSelectMatchesFilterRecordsIdsComponentState({ | ||
scopeId, | ||
}), | ||
); | ||
|
||
const relationPickerScopedId = useAvailableScopeIdOrThrow( | ||
RelationPickerScopeInternalContext, | ||
); | ||
|
||
const { relationPickerSearchFilterState } = useRelationPickerScopedStates({ | ||
relationPickerScopedId, | ||
}); | ||
const relationPickerSearchFilter = useRecoilValue( | ||
relationPickerSearchFilterState, | ||
); | ||
|
||
const { matchesSearchFilterObjectRecords } = | ||
useMultiObjectSearchMatchesSearchFilterQuery({ | ||
excludedObjects: [ | ||
CoreObjectNameSingular.Task, | ||
CoreObjectNameSingular.Note, | ||
], | ||
searchFilterValue: relationPickerSearchFilter, | ||
limit: 10, | ||
}); | ||
|
||
useEffect(() => { | ||
setRecordMultiSelectMatchesFilterRecords( | ||
matchesSearchFilterObjectRecords, | ||
); | ||
}, [ | ||
setRecordMultiSelectMatchesFilterRecords, | ||
matchesSearchFilterObjectRecords, | ||
]); | ||
|
||
return <></>; | ||
}; |
141 changes: 0 additions & 141 deletions
141
...t/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectSearch.test.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.