Removed useRecordTable (#13837)
This PR removes useRecordTable barrel-hook and instead use the pattern that enforces one hook per function. This allows to have a easier to maintain React code with small dedicated hooks. This PR also improves the usage of those hooks by cleaning some logic that calls them. We introduce a new hook : `useRecordIndexIdFromCurrentContextStore` that factorizes logic that was duplicated to retrieve the `recordTableId`. Introduced `useHandleColumnsChange`, that saves table columns into view, this could be discussed but is it isolated with a TODO comment so ok for now. Also lowered the coverage because not enough to cover with test here. --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@@ -78,7 +78,7 @@ export const PageChangeEffect = () => {
|
||||
contextStoreCurrentViewId || '',
|
||||
);
|
||||
|
||||
const resetTableSelections = useResetTableRowSelection(recordIndexId);
|
||||
const { resetTableRowSelection } = useResetTableRowSelection(recordIndexId);
|
||||
const { unfocusRecordTableRow } = useFocusedRecordTableRow(recordIndexId);
|
||||
const { deactivateRecordTableRow } = useActiveRecordTableRow(recordIndexId);
|
||||
|
||||
@@ -124,7 +124,7 @@ export const PageChangeEffect = () => {
|
||||
|
||||
if (isLeavingRecordIndexPage) {
|
||||
if (contextStoreCurrentViewType === ContextStoreViewType.Table) {
|
||||
resetTableSelections();
|
||||
resetTableRowSelection();
|
||||
unfocusRecordTableRow();
|
||||
deactivateRecordTableRow();
|
||||
}
|
||||
@@ -289,7 +289,7 @@ export const PageChangeEffect = () => {
|
||||
location,
|
||||
previousLocation,
|
||||
contextStoreCurrentViewType,
|
||||
resetTableSelections,
|
||||
resetTableRowSelection,
|
||||
unfocusRecordTableRow,
|
||||
deactivateRecordTableRow,
|
||||
resetRecordSelection,
|
||||
|
||||
Reference in New Issue
Block a user