The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
3157 refactor scoped states to move to v3 (#3180)
bosiraphaelb0d3e6d8d354
diff --git a/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx b/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsxindex 7d81562fcd8..6b285ca4f1e 100644--- a/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx+++ b/packages/twenty-front/src/modules/activities/files/components/AttachmentDropdown.tsx@@ -20,7 +20,7 @@ export const AttachmentDropdown = ({}: AttachmentDropdownProps) => {const dropdownScopeId = `${scopeKey}-settings-field-active-action-dropdown`;- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const handleDownload = () => {onDownload();diff --git a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.tsindex c5bc22f186e..b950b7a6f66 100644--- a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts+++ b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts@@ -1,7 +1,8 @@import { useRecoilCallback } from 'recoil';import { ActivityType } from '@/activities/types/Activity';-import { selectedRowIdsSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsSelector';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import {ActivityTargetableEntity,@@ -10,9 +11,16 @@ import {import { useOpenCreateActivityDrawer } from './useOpenCreateActivityDrawer';-export const useOpenCreateActivityDrawerForSelectedRowIds = () => {+export const useOpenCreateActivityDrawerForSelectedRowIds = (+ recordTableScopeId: string,+) => {const openCreateActivityDrawer = useOpenCreateActivityDrawer();+ const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();++ const { injectSelectorSnapshotValueWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableScopeId);+return useRecoilCallback(({ snapshot }) =>(@@ -20,9 +28,12 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {entityType: ActivityTargetableEntityType,relatedEntities?: ActivityTargetableEntity[],) => {- const selectedRowIds = snapshot- .getLoadable(selectedRowIdsSelector)- .getValue();+ const selectedRowIds =+ injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ selectedRowIdsScopeInjector,+ );+let activityTargetableEntityArray: ActivityTargetableEntity[] =selectedRowIds.map((id: string) => ({type: entityType,@@ -37,6 +48,10 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = () => {targetableEntities: activityTargetableEntityArray,});},- [openCreateActivityDrawer],+ [+ injectSelectorSnapshotValueWithRecordTableScopeId,+ openCreateActivityDrawer,+ selectedRowIdsScopeInjector,+ ],);};diff --git a/packages/twenty-front/src/modules/activities/timeline/utils/__tests__/groupActivitiesByMonth.test.ts b/packages/twenty-front/src/modules/activities/timeline/utils/__tests__/groupActivitiesByMonth.test.tsindex 9223f0fd351..3be8f3dd7fd 100644--- a/packages/twenty-front/src/modules/activities/timeline/utils/__tests__/groupActivitiesByMonth.test.ts+++ b/packages/twenty-front/src/modules/activities/timeline/utils/__tests__/groupActivitiesByMonth.test.ts@@ -13,10 +13,10 @@ describe('groupActivitiesByMonth', () => {expect(grouped[0].items).toHaveLength(1);expect(grouped[1].items).toHaveLength(1);- expect(grouped[0].year).toBe(2023);+ expect(grouped[0].year).toBe(new Date().getFullYear());expect(grouped[1].year).toBe(2023);- expect(grouped[0].month).toBe(11);+ expect(grouped[0].month).toBe(new Date().getMonth());expect(grouped[1].month).toBe(3);});});diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.tsindex 89e9a33b99b..0d2978c7d2d 100644--- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts+++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts@@ -23,7 +23,7 @@ export const useCommandMenu = () => {const openCommandMenu = () => {setIsCommandMenuOpened(true);- setHotkeyScopeAndMemorizePreviousScope(AppHotkeyScope.CommandMenu);+ setHotkeyScopeAndMemorizePreviousScope(AppHotkeyScope.CommandMenuOpen);};const closeCommandMenu = () => {diff --git a/packages/twenty-front/src/modules/object-record/components/RecordTableContainer.tsx b/packages/twenty-front/src/modules/object-record/components/RecordTableContainer.tsxindex 0045a462017..fb6d89b50cc 100644--- a/packages/twenty-front/src/modules/object-record/components/RecordTableContainer.tsx+++ b/packages/twenty-front/src/modules/object-record/components/RecordTableContainer.tsx@@ -28,9 +28,11 @@ const StyledContainer = styled.div``;export const RecordTableContainer = ({+ recordTableId,objectNamePlural,createRecord,}: {+ recordTableId: string;objectNamePlural: string;createRecord: () => void;}) => {@@ -52,7 +54,6 @@ export const RecordTableContainer = ({const { openPersonSpreadsheetImport } = useSpreadsheetPersonImport();const { openCompanySpreadsheetImport } = useSpreadsheetCompanyImport();- const recordTableId = objectNamePlural ?? '';const viewBarId = objectNamePlural ?? '';const { setTableFilters, setTableSorts, setTableColumns } = useRecordTable({diff --git a/packages/twenty-front/src/modules/object-record/components/RecordTablePage.tsx b/packages/twenty-front/src/modules/object-record/components/RecordTablePage.tsxindex 8aa4547604b..57c078632fd 100644--- a/packages/twenty-front/src/modules/object-record/components/RecordTablePage.tsx+++ b/packages/twenty-front/src/modules/object-record/components/RecordTablePage.tsx@@ -61,6 +61,8 @@ export const RecordTablePage = () => {await createOneObject?.({});};+ const recordTableId = objectNamePlural ?? '';+return (<PageContainer><PageHeader@@ -75,12 +77,13 @@ export const RecordTablePage = () => {<PageBody><StyledTableContainer><RecordTableContainer+ recordTableId={recordTableId}objectNamePlural={objectNamePlural}createRecord={handleAddButtonClick}/></StyledTableContainer>- <RecordTableActionBar />- <RecordTableContextMenu />+ <RecordTableActionBar recordTableId={recordTableId} />+ <RecordTableContextMenu recordTableId={recordTableId} /></PageBody></PageContainer>);diff --git a/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordTable.ts b/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordTable.tsindex 900a6f28ccc..7f112ec35d3 100644--- a/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordTable.ts+++ b/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordTable.ts@@ -7,13 +7,17 @@ import { turnSortsIntoOrderBy } from '@/object-record/object-sort-dropdown/utilsimport { turnObjectDropdownFilterIntoQueryFilter } from '@/object-record/record-filter/utils/turnObjectDropdownFilterIntoQueryFilter';import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';-import { isRecordTableInitialLoadingState } from '@/object-record/record-table/states/isRecordTableInitialLoadingState';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { signInBackgroundMockCompanies } from '@/sign-in-background-mock/constants/signInBackgroundMockCompanies';import { useFindManyRecords } from './useFindManyRecords';export const useObjectRecordTable = () => {- const { scopeId: objectNamePlural, setRecordTableData } = useRecordTable();+ const {+ scopeId: objectNamePlural,+ setRecordTableData,+ setIsRecordTableInitialLoading,+ } = useRecordTable();const currentWorkspace = useRecoilValue(currentWorkspaceState);const { objectNameSingular } = useObjectNameSingularFromPlural({@@ -25,8 +29,26 @@ export const useObjectRecordTable = () => {objectNameSingular,},);- const { tableFiltersState, tableSortsState, tableLastRowVisibleState } =- useRecordTableScopedStates();++ const {+ tableFiltersScopeInjector,+ tableSortsScopeInjector,+ tableLastRowVisibleScopeInjector,+ } = getRecordTableScopeInjector();++ const { injectStateWithRecordTableScopeId } = useRecordTableScopedStates();++ const tableFiltersState = injectStateWithRecordTableScopeId(+ tableFiltersScopeInjector,+ );++ const tableSortsState = injectStateWithRecordTableScopeId(+ tableSortsScopeInjector,+ );++ const tableLastRowVisibleState = injectStateWithRecordTableScopeId(+ tableLastRowVisibleScopeInjector,+ );const tableFilters = useRecoilValue(tableFiltersState);const tableSorts = useRecoilValue(tableSortsState);@@ -42,10 +64,6 @@ export const useObjectRecordTable = () => {foundObjectMetadataItem?.fields ?? [],);- const setIsRecordTableInitialLoading = useSetRecoilState(- isRecordTableInitialLoadingState,- );-const { records, loading, fetchMoreRecords, queryStateIdentifier } =useFindManyRecords({objectNameSingular,diff --git a/packages/twenty-front/src/modules/object-record/hooks/useRecordTableContextMenuEntries.tsx b/packages/twenty-front/src/modules/object-record/hooks/useRecordTableContextMenuEntries.tsxindex 748a7871d8a..70737f1f812 100644--- a/packages/twenty-front/src/modules/object-record/hooks/useRecordTableContextMenuEntries.tsx+++ b/packages/twenty-front/src/modules/object-record/hooks/useRecordTableContextMenuEntries.tsx@@ -8,9 +8,10 @@ import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjeimport { entityFieldsFamilyState } from '@/object-record/field/states/entityFieldsFamilyState';import { useDeleteManyRecords } from '@/object-record/hooks/useDeleteManyRecords';import { useExecuteQuickActionOnOneRecord } from '@/object-record/hooks/useExecuteQuickActionOnOneRecord';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';-import { selectedRowIdsSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsSelector';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import {IconCheckbox,IconHeart,@@ -41,12 +42,25 @@ export const useRecordTableContextMenuEntries = (const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState);const setActionBarEntriesState = useSetRecoilState(actionBarEntriesState);+ const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();++ const {+ injectSelectorWithRecordTableScopeId,+ injectSelectorSnapshotValueWithRecordTableScopeId,+ } = useRecordTableScopedStates(scopeId);++ const selectedRowIdsSelector = injectSelectorWithRecordTableScopeId(+ selectedRowIdsScopeInjector,+ );+const selectedRowIds = useRecoilValue(selectedRowIdsSelector);- const { scopeId: objectNamePlural, resetTableRowSelection } = useRecordTable({+ const { resetTableRowSelection } = useRecordTable({recordTableScopeId: scopeId,});+ const objectNamePlural = scopeId;+const { objectNameSingular } = useObjectNameSingularFromPlural({objectNamePlural,});@@ -61,9 +75,10 @@ export const useRecordTableContextMenuEntries = (: 'Custom';const handleFavoriteButtonClick = useRecoilCallback(({ snapshot }) => () => {- const selectedRowIds = snapshot- .getLoadable(selectedRowIdsSelector)- .getValue();+ const selectedRowIds = injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ selectedRowIdsScopeInjector,+ );const selectedRowId = selectedRowIds.length === 1 ? selectedRowIds[0] : '';@@ -97,22 +112,31 @@ export const useRecordTableContextMenuEntries = (const handleDeleteClick = useRecoilCallback(({ snapshot }) =>async () => {- const rowIdsToDelete = snapshot- .getLoadable(selectedRowIdsSelector)- .getValue();+ const rowIdsToDelete =+ injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ selectedRowIdsScopeInjector,+ );resetTableRowSelection();await deleteManyRecords(rowIdsToDelete);},- [deleteManyRecords, resetTableRowSelection],+ [+ deleteManyRecords,+ injectSelectorSnapshotValueWithRecordTableScopeId,+ resetTableRowSelection,+ selectedRowIdsScopeInjector,+ ],);const handleExecuteQuickActionOnClick = useRecoilCallback(({ snapshot }) =>async () => {- const rowIdsToExecuteQuickActionOn = snapshot- .getLoadable(selectedRowIdsSelector)- .getValue();+ const rowIdsToExecuteQuickActionOn =+ injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ selectedRowIdsScopeInjector,+ );resetTableRowSelection();await Promise.all(@@ -121,7 +145,12 @@ export const useRecordTableContextMenuEntries = (}),);},- [executeQuickActionOnOneRecord, resetTableRowSelection],+ [+ executeQuickActionOnOneRecord,+ injectSelectorSnapshotValueWithRecordTableScopeId,+ resetTableRowSelection,+ selectedRowIdsScopeInjector,+ ],);const dataExecuteQuickActionOnmentEnabled = useIsFeatureEnabled(@@ -129,7 +158,7 @@ export const useRecordTableContextMenuEntries = ();const openCreateActivityDrawer =- useOpenCreateActivityDrawerForSelectedRowIds();+ useOpenCreateActivityDrawerForSelectedRowIds(scopeId);return {setContextMenuEntries: useCallback(() => {diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/AddObjectFilterFromDetailsButton.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/AddObjectFilterFromDetailsButton.tsxindex ec62fa84554..b1347ed391a 100644--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/AddObjectFilterFromDetailsButton.tsx+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/AddObjectFilterFromDetailsButton.tsx@@ -12,9 +12,7 @@ type AddObjectFilterFromDetailsButtonProps = {export const AddObjectFilterFromDetailsButton = ({filterDropdownId,}: AddObjectFilterFromDetailsButtonProps) => {- const { toggleDropdown } = useDropdown({- dropdownScopeId: ObjectFilterDropdownId,- });+ const { toggleDropdown } = useDropdown(ObjectFilterDropdownId);const { resetFilter } = useFilterDropdown({filterDropdownId: filterDropdownId,diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersButton.tsx b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersButton.tsxindex 84b8494b5ae..2da7b144ef8 100644--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersButton.tsx+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/components/MultipleFiltersButton.tsx@@ -7,9 +7,9 @@ import { ObjectFilterDropdownId } from '../constants/ObjectFilterDropdownId';export const MultipleFiltersButton = () => {const { resetFilter } = useFilterDropdown();- const { isDropdownOpen, toggleDropdown } = useDropdown({- dropdownScopeId: ObjectFilterDropdownId,- });+ const { isDropdownOpen, toggleDropdown } = useDropdown(+ ObjectFilterDropdownId,+ );const handleClick = () => {toggleDropdown();diff --git a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsxindex ed3f8e3ca76..02ca6865735 100644--- a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx+++ b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/components/ObjectSortDropdownButton.tsx@@ -42,9 +42,7 @@ export const ObjectSortDropdownButton = ({sortDropdownId: sortDropdownId,});- const { toggleDropdown } = useDropdown({- dropdownScopeId: ObjectSortDropdownId,- });+ const { toggleDropdown } = useDropdown(ObjectSortDropdownId);const handleButtonClick = () => {toggleDropdown();diff --git a/packages/twenty-front/src/modules/object-record/record-table/action-bar/components/RecordTableActionBar.tsx b/packages/twenty-front/src/modules/object-record/record-table/action-bar/components/RecordTableActionBar.tsxindex 6ea19c23417..4842bf591b6 100644--- a/packages/twenty-front/src/modules/object-record/record-table/action-bar/components/RecordTableActionBar.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/action-bar/components/RecordTableActionBar.tsx@@ -1,11 +1,23 @@-import React from 'react';import { useRecoilValue } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { ActionBar } from '@/ui/navigation/action-bar/components/ActionBar';-import { selectedRowIdsSelector } from '../../states/selectors/selectedRowIdsSelector';+export const RecordTableActionBar = ({+ recordTableId,+}: {+ recordTableId: string;+}) => {+ const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableId);++ const selectedRowIdsSelector = injectSelectorWithRecordTableScopeId(+ selectedRowIdsScopeInjector,+ );-export const RecordTableActionBar = () => {const selectedRowIds = useRecoilValue(selectedRowIdsSelector);return <ActionBar selectedIds={selectedRowIds} />;diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBody.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBody.tsxindex d5e949649a3..a3d3889a6bf 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBody.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBody.tsx@@ -4,9 +4,18 @@ import { RecordTableBodyFetchMoreLoader } from '@/object-record/record-table/comimport { RecordTableRow } from '@/object-record/record-table/components/RecordTableRow';import { RowIdContext } from '@/object-record/record-table/contexts/RowIdContext';import { RowIndexContext } from '@/object-record/record-table/contexts/RowIndexContext';-import { tableRowIdsState } from '@/object-record/record-table/states/tableRowIdsState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';export const RecordTableBody = () => {+ const { tableRowIdsScopeInjector } = getRecordTableScopeInjector();++ const { injectStateWithRecordTableScopeId } = useRecordTableScopedStates();++ const tableRowIdsState = injectStateWithRecordTableScopeId(+ tableRowIdsScopeInjector,+ );+const tableRowIds = useRecoilValue(tableRowIdsState);return (diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyEffect.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyEffect.tsxindex 06265fdc387..c5d2a26db90 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyEffect.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyEffect.tsx@@ -3,6 +3,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';import { useObjectRecordTable } from '@/object-record/hooks/useObjectRecordTable';import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { isFetchingMoreRecordsFamilyState } from '@/object-record/states/isFetchingMoreRecordsFamilyState';export const RecordTableBodyEffect = () => {@@ -13,7 +14,15 @@ export const RecordTableBodyEffect = () => {queryStateIdentifier,loading,} = useObjectRecordTable();- const { tableLastRowVisibleState } = useRecordTableScopedStates();++ const { tableLastRowVisibleScopeInjector } = getRecordTableScopeInjector();++ const { injectStateWithRecordTableScopeId } = useRecordTableScopedStates();++ const tableLastRowVisibleState = injectStateWithRecordTableScopeId(+ tableLastRowVisibleScopeInjector,+ );+const [tableLastRowVisible, setTableLastRowVisible] = useRecoilState(tableLastRowVisibleState,);diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyFetchMoreLoader.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyFetchMoreLoader.tsxindex aa212ac7726..337494aec2b 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyFetchMoreLoader.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableBodyFetchMoreLoader.tsx@@ -4,26 +4,21 @@ import { useRecoilCallback, useRecoilValue } from 'recoil';import { useObjectRecordTable } from '@/object-record/hooks/useObjectRecordTable';import { StyledRow } from '@/object-record/record-table/components/RecordTableRow';import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';-import { getRecordTableScopedStates } from '@/object-record/record-table/utils/getRecordTableScopedStates';import { isFetchingMoreRecordsFamilyState } from '@/object-record/states/isFetchingMoreRecordsFamilyState';export const RecordTableBodyFetchMoreLoader = () => {const { queryStateIdentifier } = useObjectRecordTable();- const { scopeId } = useRecordTable();+ const { setRecordTableLastRowVisible } = useRecordTable();const isFetchingMoreObjects = useRecoilValue(isFetchingMoreRecordsFamilyState(queryStateIdentifier),);const onLastRowVisible = useRecoilCallback(- ({ set }) =>- async (inView: boolean) => {- const { tableLastRowVisibleState } = getRecordTableScopedStates({- recordTableScopeId: scopeId,- });- set(tableLastRowVisibleState, inView);- },- [scopeId],+ () => async (inView: boolean) => {+ setRecordTableLastRowVisible(inView);+ },+ [setRecordTableLastRowVisible],);const { ref: tbodyRef } = useInView({diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCell.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsxsimilarity index 81%rename from packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCell.tsxrename to packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsxindex 06702d3672e..66338a68d89 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCell.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsx@@ -2,6 +2,7 @@ import { useContext } from 'react';import { useRecoilValue, useSetRecoilState } from 'recoil';import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { RelationPickerHotkeyScope } from '@/object-record/relation-picker/types/RelationPickerHotkeyScope';import { contextMenuIsOpenState } from '@/ui/navigation/context-menu/states/contextMenuIsOpenState';import { contextMenuPositionState } from '@/ui/navigation/context-menu/states/contextMenuPositionState';@@ -13,17 +14,25 @@ import { ColumnContext } from '../contexts/ColumnContext';import { ColumnIndexContext } from '../contexts/ColumnIndexContext';import { RecordUpdateContext } from '../contexts/EntityUpdateMutationHookContext';import { RowIdContext } from '../contexts/RowIdContext';-import { TableCell } from '../record-table-cell/components/RecordTableCell';+import { RecordTableCell } from '../record-table-cell/components/RecordTableCell';import { useCurrentRowSelected } from '../record-table-row/hooks/useCurrentRowSelected';import { TableHotkeyScope } from '../types/TableHotkeyScope';-export const RecordTableCell = ({ cellIndex }: { cellIndex: number }) => {+export const RecordTableCellContainer = ({+ cellIndex,+}: {+ cellIndex: number;+}) => {const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);const currentRowId = useContext(RowIdContext);- const { objectMetadataConfigState } = useRecordTableScopedStates();+ const { objectMetadataConfigScopeInjector } = getRecordTableScopeInjector();- const objectMetadataConfig = useRecoilValue(objectMetadataConfigState);+ const { injectStateWithRecordTableScopeId } = useRecordTableScopedStates();++ const objectMetadataConfig = useRecoilValue(+ injectStateWithRecordTableScopeId(objectMetadataConfigScopeInjector),+ );const { setCurrentRowSelected } = useCurrentRowSelected();@@ -66,7 +75,7 @@ export const RecordTableCell = ({ cellIndex }: { cellIndex: number }) => {objectMetadataConfig?.labelIdentifierFieldMetadataId,}}>- <TableCell customHotkeyScope={{ scope: customHotkeyScope }} />+ <RecordTableCell customHotkeyScope={{ scope: customHotkeyScope }} /></FieldContext.Provider></td></ColumnIndexContext.Provider>diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsxindex aa12928720f..d43ac048ba6 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeader.tsx@@ -3,6 +3,7 @@ import styled from '@emotion/styled';import { useRecoilValue } from 'recoil';import { RecordTableHeaderCell } from '@/object-record/record-table/components/RecordTableHeaderCell';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { IconPlus } from '@/ui/display/icon';import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';@@ -58,8 +59,18 @@ export const RecordTableHeader = ({}: {createRecord: () => void;}) => {- const { hiddenTableColumnsSelector, visibleTableColumnsSelector } =- useRecordTableScopedStates();+ const { hiddenTableColumnsScopeInjector, visibleTableColumnsScopeInjector } =+ getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } = useRecordTableScopedStates();++ const hiddenTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ hiddenTableColumnsScopeInjector,+ );++ const visibleTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ visibleTableColumnsScopeInjector,+ );const hiddenTableColumns = useRecoilValue(hiddenTableColumnsSelector);diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsxindex 25d3aeb608d..aaf70d559bc 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx@@ -5,8 +5,8 @@ import { useRecoilCallback, useRecoilState, useRecoilValue } from 'recoil';import { FieldMetadata } from '@/object-record/field/types/FieldMetadata';import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';import { useTableColumns } from '@/object-record/record-table/hooks/useTableColumns';-import { resizeFieldOffsetState } from '@/object-record/record-table/states/resizeFieldOffsetState';import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { IconPlus } from '@/ui/display/icon';import { LightIconButton } from '@/ui/input/button/components/LightIconButton';import { useTrackPointer } from '@/ui/utilities/pointer-event/hooks/useTrackPointer';@@ -80,15 +80,38 @@ export const RecordTableHeaderCell = ({column: ColumnDefinition<FieldMetadata>;createRecord: () => void;}) => {+ const {+ resizeFieldOffsetScopeInjector,+ tableColumnsScopeInjector,+ tableColumnsByKeyScopeInjector,+ visibleTableColumnsScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectStateWithRecordTableScopeId,+ injectSelectorWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ } = useRecordTableScopedStates();++ const resizeFieldOffsetState = injectStateWithRecordTableScopeId(+ resizeFieldOffsetScopeInjector,+ );+const [resizeFieldOffset, setResizeFieldOffset] = useRecoilState(resizeFieldOffsetState,);- const {- tableColumnsState,- tableColumnsByKeySelector,- visibleTableColumnsSelector,- } = useRecordTableScopedStates();+ const tableColumnsState = injectStateWithRecordTableScopeId(+ tableColumnsScopeInjector,+ );++ const tableColumnsByKeySelector = injectSelectorWithRecordTableScopeId(+ tableColumnsByKeyScopeInjector,+ );++ const visibleTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ visibleTableColumnsScopeInjector,+ );const tableColumns = useRecoilValue(tableColumnsState);const tableColumnsByKey = useRecoilValue(tableColumnsByKeySelector);@@ -124,10 +147,14 @@ export const RecordTableHeaderCell = ({async () => {if (!resizedFieldKey) return;+ const resizeFieldOffset = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ resizeFieldOffsetScopeInjector,+ );+const nextWidth = Math.round(Math.max(- tableColumnsByKey[resizedFieldKey].size +- snapshot.getLoadable(resizeFieldOffsetState).valueOrThrow(),+ tableColumnsByKey[resizedFieldKey].size + resizeFieldOffset,COLUMN_MIN_WIDTH,),);@@ -146,7 +173,15 @@ export const RecordTableHeaderCell = ({await handleColumnsChange(nextColumns);}},- [resizedFieldKey, tableColumnsByKey, tableColumns, handleColumnsChange],+ [+ resizedFieldKey,+ injectSnapshotValueWithRecordTableScopeId,+ resizeFieldOffsetScopeInjector,+ tableColumnsByKey,+ resizeFieldOffsetState,+ tableColumns,+ handleColumnsChange,+ ],);useTrackPointer({diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderPlusButtonContent.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderPlusButtonContent.tsxindex 5a0ce8d679d..6b54bb31be5 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderPlusButtonContent.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderPlusButtonContent.tsx@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';import styled from '@emotion/styled';import { useRecoilValue } from 'recoil';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { IconSettings } from '@/ui/display/icon';import { useIcons } from '@/ui/display/icon/hooks/useIcons';import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';@@ -18,7 +19,13 @@ import { ColumnDefinition } from '../types/ColumnDefinition';export const RecordTableHeaderPlusButtonContent = () => {const { closeDropdown } = useDropdown();- const { hiddenTableColumnsSelector } = useRecordTableScopedStates();+ const { hiddenTableColumnsScopeInjector } = getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } = useRecordTableScopedStates();++ const hiddenTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ hiddenTableColumnsScopeInjector,+ );const hiddenTableColumns = useRecoilValue(hiddenTableColumnsSelector);diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableRow.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableRow.tsxindex 38788a170db..667b8a239c7 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableRow.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableRow.tsx@@ -3,6 +3,8 @@ import { useInView } from 'react-intersection-observer';import styled from '@emotion/styled';import { useRecoilValue } from 'recoil';+import { RecordTableCellContainer } from '@/object-record/record-table/components/RecordTableCellContainer';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { ScrollWrapperContext } from '@/ui/utilities/scroll/components/ScrollWrapper';import { ColumnContext } from '../contexts/ColumnContext';@@ -10,7 +12,6 @@ import { useRecordTableScopedStates } from '../hooks/internal/useRecordTableScopimport { useCurrentRowSelected } from '../record-table-row/hooks/useCurrentRowSelected';import { CheckboxCell } from './CheckboxCell';-import { RecordTableCell } from './RecordTableCell';export const StyledRow = styled.tr<{ selected: boolean }>`background: ${(props) =>@@ -26,7 +27,13 @@ const StyledPlaceholder = styled.td``;export const RecordTableRow = ({ rowId }: RecordTableRowProps) => {- const { visibleTableColumnsSelector } = useRecordTableScopedStates();+ const { visibleTableColumnsScopeInjector } = getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } = useRecordTableScopedStates();++ const visibleTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ visibleTableColumnsScopeInjector,+ );const visibleTableColumns = useRecoilValue(visibleTableColumnsSelector);@@ -59,7 +66,7 @@ export const RecordTableRow = ({ rowId }: RecordTableRowProps) => {value={column}key={column.fieldMetadataId}>- <RecordTableCell cellIndex={columnIndex} />+ <RecordTableCellContainer cellIndex={columnIndex} /></ColumnContext.Provider>);})}diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableWithWrappers.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableWithWrappers.tsxindex 2fe1effa674..b99e6daa53a 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableWithWrappers.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableWithWrappers.tsx@@ -7,7 +7,8 @@ import { useObjectNameSingularFromPlural } from '@/object-metadata/hooks/useObjeimport { RecordTable } from '@/object-record/record-table/components/RecordTable';import { RecordTableFirstColumnScrollObserver } from '@/object-record/record-table/components/RecordTableFirstColumnScrollObserver';import { RecordTableRefContextWrapper } from '@/object-record/record-table/components/RecordTableRefContext';-import { isRecordTableInitialLoadingState } from '@/object-record/record-table/states/isRecordTableInitialLoadingState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { IconPlus } from '@/ui/display/icon';import { Button } from '@/ui/input/button/components/Button';import { DragSelect } from '@/ui/utilities/drag-select/components/DragSelect';@@ -18,7 +19,6 @@ import { mapColumnDefinitionsToViewFields } from '@/views/utils/mapColumnDefinitimport { RecordUpdateContext } from '../contexts/EntityUpdateMutationHookContext';import { useRecordTable } from '../hooks/useRecordTable';import { RecordTableScope } from '../scopes/RecordTableScope';-import { numberOfTableRowsState } from '../states/numberOfTableRowsState';import { RecordTableInternalEffect } from './RecordTableInternalEffect';@@ -80,6 +80,22 @@ export const RecordTableWithWrappers = ({}: RecordTableWithWrappersProps) => {const tableBodyRef = useRef<HTMLDivElement>(null);+ const {+ numberOfTableRowsScopeInjector,+ isRecordTableInitialLoadingScopeInjector,+ } = getRecordTableScopeInjector();++ const { injectStateWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableId);++ const numberOfTableRowsState = injectStateWithRecordTableScopeId(+ numberOfTableRowsScopeInjector,+ );++ const isRecordTableInitialLoadingState = injectStateWithRecordTableScopeId(+ isRecordTableInitialLoadingScopeInjector,+ );+const numberOfTableRows = useRecoilValue(numberOfTableRowsState);const isRecordTableInitialLoading = useRecoilValue(diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/SelectAllCheckbox.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/SelectAllCheckbox.tsxindex 359e590fd33..4dca81427cb 100644--- a/packages/twenty-front/src/modules/object-record/record-table/components/SelectAllCheckbox.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/components/SelectAllCheckbox.tsx@@ -1,10 +1,11 @@import styled from '@emotion/styled';import { useRecoilValue } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { Checkbox } from '@/ui/input/components/Checkbox';import { useRecordTable } from '../hooks/useRecordTable';-import { allRowsSelectedStatusSelector } from '../states/selectors/allRowsSelectedStatusSelector';const StyledContainer = styled.div`align-items: center;@@ -16,7 +17,16 @@ const StyledContainer = styled.div``;export const SelectAllCheckbox = () => {- const allRowsSelectedStatus = useRecoilValue(allRowsSelectedStatusSelector);+ const { allRowsSelectedStatusScopeInjector } = getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } = useRecordTableScopedStates();++ const allRowsSelectedStatusScopedSelector =+ injectSelectorWithRecordTableScopeId(allRowsSelectedStatusScopeInjector);++ const allRowsSelectedStatus = useRecoilValue(+ allRowsSelectedStatusScopedSelector,+ );const { selectAllRows } = useRecordTable();const checked = allRowsSelectedStatus === 'all';diff --git a/packages/twenty-front/src/modules/object-record/record-table/context-menu/components/RecordTableContextMenu.tsx b/packages/twenty-front/src/modules/object-record/record-table/context-menu/components/RecordTableContextMenu.tsxindex c96ea98e7d2..28144d8940b 100644--- a/packages/twenty-front/src/modules/object-record/record-table/context-menu/components/RecordTableContextMenu.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/context-menu/components/RecordTableContextMenu.tsx@@ -1,11 +1,24 @@-import React from 'react';import { useRecoilValue } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { ContextMenu } from '@/ui/navigation/context-menu/components/ContextMenu';-import { selectedRowIdsSelector } from '../../states/selectors/selectedRowIdsSelector';+export const RecordTableContextMenu = ({+ recordTableId,+}: {+ recordTableId: string;+}) => {+ const { selectedRowIdsScopeInjector } = getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableId);++ const selectedRowIdsSelector = injectSelectorWithRecordTableScopeId(+ selectedRowIdsScopeInjector,+ );-export const RecordTableContextMenu = () => {const selectedRowIds = useRecoilValue(selectedRowIdsSelector);+return <ContextMenu selectedIds={selectedRowIds} />;};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useCloseCurrentTableCellInEditMode.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useCloseCurrentTableCellInEditMode.tsindex cc667e1e8d9..f55a35743b3 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useCloseCurrentTableCellInEditMode.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useCloseCurrentTableCellInEditMode.ts@@ -1,18 +1,42 @@import { useRecoilCallback } from 'recoil';-import { currentTableCellInEditModePositionState } from '../../states/currentTableCellInEditModePositionState';-import { isTableCellInEditModeFamilyState } from '../../states/isTableCellInEditModeFamilyState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';-export const useCloseCurrentTableCellInEditMode = () =>- useRecoilCallback(({ set, snapshot }) => {- return async () => {- const currentTableCellInEditModePosition = snapshot- .getLoadable(currentTableCellInEditModePositionState)- .valueOrThrow();+export const useCloseCurrentTableCellInEditMode = (+ recordTableScopeId: string,+) => {+ const {+ currentTableCellInEditModePositionScopeInjector,+ isTableCellInEditModeScopeInjector,+ } = getRecordTableScopeInjector();- set(- isTableCellInEditModeFamilyState(currentTableCellInEditModePosition),- false,- );- };- }, []);+ const {+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);++ return useRecoilCallback(+ ({ set, snapshot }) => {+ return async () => {+ const currentTableCellInEditModePosition =+ injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ currentTableCellInEditModePositionScopeInjector,+ );++ const isTableCellInEditMode = injectFamilyStateWithRecordTableScopeId(+ isTableCellInEditModeScopeInjector,+ );++ set(isTableCellInEditMode(currentTableCellInEditModePosition), false);+ };+ },+ [+ currentTableCellInEditModePositionScopeInjector,+ injectFamilyStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ isTableCellInEditModeScopeInjector,+ ],+ );+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useDisableSoftFocus.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useDisableSoftFocus.tsindex 316e219d86c..1eef7e7f171 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useDisableSoftFocus.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useDisableSoftFocus.ts@@ -1,18 +1,50 @@import { useRecoilCallback } from 'recoil';-import { isSoftFocusActiveState } from '../../states/isSoftFocusActiveState';-import { isSoftFocusOnTableCellFamilyState } from '../../states/isSoftFocusOnTableCellFamilyState';-import { softFocusPositionState } from '../../states/softFocusPositionState';--export const useDisableSoftFocus = () =>- useRecoilCallback(({ set, snapshot }) => {- return () => {- const currentPosition = snapshot- .getLoadable(softFocusPositionState)- .valueOrThrow();-- set(isSoftFocusActiveState, false);-- set(isSoftFocusOnTableCellFamilyState(currentPosition), false);- };- }, []);+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';++export const useDisableSoftFocus = (recordTableScopeId: string) => {+ const {+ softFocusPositionScopeInjector,+ isSoftFocusActiveScopeInjector,+ isSoftFocusOnTableCellScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);++ return useRecoilCallback(+ ({ set, snapshot }) => {+ return () => {+ const currentPosition = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ softFocusPositionScopeInjector,+ );++ const isSoftFocusActiveState = injectStateWithRecordTableScopeId(+ isSoftFocusActiveScopeInjector,+ );++ const isSoftFocusOnTableCellFamilyState =+ injectFamilyStateWithRecordTableScopeId(+ isSoftFocusOnTableCellScopeInjector,+ );++ set(isSoftFocusActiveState, false);++ set(isSoftFocusOnTableCellFamilyState(currentPosition), false);+ };+ },+ [+ injectFamilyStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectStateWithRecordTableScopeId,+ isSoftFocusActiveScopeInjector,+ isSoftFocusOnTableCellScopeInjector,+ softFocusPositionScopeInjector,+ ],+ );+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useGetIsSomeCellInEditMode.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useGetIsSomeCellInEditMode.tsindex 2bf00436b61..b4d90a942ca 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useGetIsSomeCellInEditMode.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useGetIsSomeCellInEditMode.ts@@ -1,26 +1,45 @@import { useRecoilCallback } from 'recoil';-import { currentTableCellInEditModePositionState } from '../../states/currentTableCellInEditModePositionState';-import { isTableCellInEditModeFamilyState } from '../../states/isTableCellInEditModeFamilyState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';++export const useGetIsSomeCellInEditMode = (recordTableScopeId: string) => {+ const {+ currentTableCellInEditModePositionScopeInjector,+ isTableCellInEditModeScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilySnapshotValueWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);-export const useGetIsSomeCellInEditMode = () => {return useRecoilCallback(({ snapshot }) =>() => {- const currentTableCellInEditModePosition = snapshot- .getLoadable(currentTableCellInEditModePositionState)- .valueOrThrow();+ const currentTableCellInEditModePosition =+ injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ currentTableCellInEditModePositionScopeInjector,+ );++ const isSomeCellInEditModeFamilyState =+ injectFamilySnapshotValueWithRecordTableScopeId(+ snapshot,+ isTableCellInEditModeScopeInjector,+ );- const isSomeCellInEditMode = snapshot- .getLoadable(- isTableCellInEditModeFamilyState(- currentTableCellInEditModePosition,- ),- )- .valueOrThrow();+ const isSomeCellInEditMode = isSomeCellInEditModeFamilyState(+ currentTableCellInEditModePosition,+ );return isSomeCellInEditMode;},- [],+ [+ currentTableCellInEditModePositionScopeInjector,+ injectFamilySnapshotValueWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ isTableCellInEditModeScopeInjector,+ ],);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.tsindex 87c1950ef36..2b4dae2b66a 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts@@ -1,23 +1,31 @@import { useRecoilCallback } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { currentHotkeyScopeState } from '@/ui/utilities/hotkey/states/internal/currentHotkeyScopeState';-import { isSoftFocusActiveState } from '../../states/isSoftFocusActiveState';import { TableHotkeyScope } from '../../types/TableHotkeyScope';import { useCloseCurrentTableCellInEditMode } from './useCloseCurrentTableCellInEditMode';import { useDisableSoftFocus } from './useDisableSoftFocus';-export const useLeaveTableFocus = () => {- const disableSoftFocus = useDisableSoftFocus();- const closeCurrentCellInEditMode = useCloseCurrentTableCellInEditMode();+export const useLeaveTableFocus = (recordTableScopeId: string) => {+ const disableSoftFocus = useDisableSoftFocus(recordTableScopeId);+ const closeCurrentCellInEditMode =+ useCloseCurrentTableCellInEditMode(recordTableScopeId);++ const { isSoftFocusActiveScopeInjector } = getRecordTableScopeInjector();++ const { injectSnapshotValueWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableScopeId);return useRecoilCallback(({ snapshot }) =>() => {- const isSoftFocusActive = snapshot- .getLoadable(isSoftFocusActiveState)- .valueOrThrow();+ const isSoftFocusActive = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ isSoftFocusActiveScopeInjector,+ );const currentHotkeyScope = snapshot.getLoadable(currentHotkeyScopeState)@@ -34,6 +42,11 @@ export const useLeaveTableFocus = () => {closeCurrentCellInEditMode();disableSoftFocus();},- [closeCurrentCellInEditMode, disableSoftFocus],+ [+ closeCurrentCellInEditMode,+ disableSoftFocus,+ injectSnapshotValueWithRecordTableScopeId,+ isSoftFocusActiveScopeInjector,+ ],);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useMoveEditModeToCellPosition.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useMoveEditModeToCellPosition.tsindex 2a24f1b71b2..b0e46996a33 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useMoveEditModeToCellPosition.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useMoveEditModeToCellPosition.ts@@ -1,23 +1,59 @@import { useRecoilCallback } from 'recoil';-import { currentTableCellInEditModePositionState } from '../../states/currentTableCellInEditModePositionState';-import { isTableCellInEditModeFamilyState } from '../../states/isTableCellInEditModeFamilyState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';+import { TableCellPosition } from '../../types/TableCellPosition';-export const useMoveEditModeToTableCellPosition = () =>- useRecoilCallback(({ set, snapshot }) => {- return (newPosition: TableCellPosition) => {- const currentTableCellInEditModePosition = snapshot- .getLoadable(currentTableCellInEditModePositionState)- .valueOrThrow();+export const useMoveEditModeToTableCellPosition = (+ recordTableScopeId: string,+) => {+ const {+ isTableCellInEditModeScopeInjector,+ currentTableCellInEditModePositionScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);++ return useRecoilCallback(+ ({ set, snapshot }) => {+ return (newPosition: TableCellPosition) => {+ const currentTableCellInEditModePosition =+ injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ currentTableCellInEditModePositionScopeInjector,+ );++ const currentTableCellInEditModePositionState =+ injectStateWithRecordTableScopeId(+ currentTableCellInEditModePositionScopeInjector,+ );++ const isTableCellInEditModeFamilyState =+ injectFamilyStateWithRecordTableScopeId(+ isTableCellInEditModeScopeInjector,+ );- set(- isTableCellInEditModeFamilyState(currentTableCellInEditModePosition),- false,- );+ set(+ isTableCellInEditModeFamilyState(currentTableCellInEditModePosition),+ false,+ );- set(currentTableCellInEditModePositionState, newPosition);+ set(currentTableCellInEditModePositionState, newPosition);- set(isTableCellInEditModeFamilyState(newPosition), true);- };- }, []);+ set(isTableCellInEditModeFamilyState(newPosition), true);+ };+ },+ [+ currentTableCellInEditModePositionScopeInjector,+ injectFamilyStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectStateWithRecordTableScopeId,+ isTableCellInEditModeScopeInjector,+ ],+ );+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableScopedStates.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableScopedStates.tsindex 3f786b12dd9..291272e92c1 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableScopedStates.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableScopedStates.ts@@ -1,46 +1,31 @@import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';+import { useScopedState } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState';-import { getRecordTableScopedStates } from '../../utils/getRecordTableScopedStates';--export const useRecordTableScopedStates = (args?: {- customRecordTableScopeId?: string;-}) => {- const { customRecordTableScopeId } = args ?? {};-+export const useRecordTableScopedStates = (recordTableId?: string) => {const scopeId = useAvailableScopeIdOrThrow(RecordTableScopeInternalContext,- customRecordTableScopeId,+ recordTableId,);const {- availableTableColumnsState,- tableFiltersState,- tableSortsState,- tableColumnsState,- objectMetadataConfigState,- tableColumnsByKeySelector,- hiddenTableColumnsSelector,- visibleTableColumnsSelector,- onEntityCountChangeState,- onColumnsChangeState,- tableLastRowVisibleState,- } = getRecordTableScopedStates({- recordTableScopeId: scopeId,- });+ getScopedState,+ getScopedSelector,+ getScopedFamilyState,+ getScopedSnapshotValue,+ getScopedSelectorSnapshotValue,+ getScopedFamilySnapshotValue,+ } = useScopedState(scopeId);return {scopeId,- availableTableColumnsState,- tableFiltersState,- tableSortsState,- tableColumnsState,- objectMetadataConfigState,- tableColumnsByKeySelector,- hiddenTableColumnsSelector,- visibleTableColumnsSelector,- onEntityCountChangeState,- onColumnsChangeState,- tableLastRowVisibleState,+ injectStateWithRecordTableScopeId: getScopedState,+ injectSelectorWithRecordTableScopeId: getScopedSelector,+ injectFamilyStateWithRecordTableScopeId: getScopedFamilyState,+ injectSelectorSnapshotValueWithRecordTableScopeId:+ getScopedSelectorSnapshotValue,+ injectSnapshotValueWithRecordTableScopeId: getScopedSnapshotValue,+ injectFamilySnapshotValueWithRecordTableScopeId:+ getScopedFamilySnapshotValue,};};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.tsindex 4584aefdd82..4255269433e 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useResetTableRowSelection.ts@@ -1,19 +1,37 @@import { useRecoilCallback } from 'recoil';-import { isRowSelectedFamilyState } from '../../record-table-row/states/isRowSelectedFamilyState';-import { tableRowIdsState } from '../../states/tableRowIdsState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';-export const useResetTableRowSelection = () =>- useRecoilCallback(+export const useResetTableRowSelection = (recordTableScopeId: string) => {+ const { tableRowIdsScopeInjector, isRowSelectedScopeInjector } =+ getRecordTableScopeInjector();++ const {+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);++ return useRecoilCallback(({ snapshot, set }) =>() => {- const tableRowIds = snapshot- .getLoadable(tableRowIdsState)- .valueOrThrow();+ const tableRowIds = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ tableRowIdsScopeInjector,+ );++ const isRowSelectedFamilyState =+ injectFamilyStateWithRecordTableScopeId(isRowSelectedScopeInjector);for (const rowId of tableRowIds) {set(isRowSelectedFamilyState(rowId), false);}},- [],+ [+ injectFamilyStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ isRowSelectedScopeInjector,+ tableRowIdsScopeInjector,+ ],);+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.tsindex f1ade5ed408..0dee68b6a4f 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSelectAllRows.ts@@ -1,20 +1,37 @@import { useRecoilCallback } from 'recoil';-import { isRowSelectedFamilyState } from '../../record-table-row/states/isRowSelectedFamilyState';-import { allRowsSelectedStatusSelector } from '../../states/selectors/allRowsSelectedStatusSelector';-import { tableRowIdsState } from '../../states/tableRowIdsState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';++export const useSelectAllRows = (recordTableScopeId: string) => {+ const {+ allRowsSelectedStatusScopeInjector,+ tableRowIdsScopeInjector,+ isRowSelectedScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectSnapshotValueWithRecordTableScopeId,+ injectSelectorSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);-export const useSelectAllRows = () => {const selectAllRows = useRecoilCallback(({ set, snapshot }) =>() => {- const allRowsSelectedStatus = snapshot- .getLoadable(allRowsSelectedStatusSelector)- .valueOrThrow();+ const allRowsSelectedStatus =+ injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ allRowsSelectedStatusScopeInjector,+ );++ const tableRowIds = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ tableRowIdsScopeInjector,+ );- const tableRowIds = snapshot- .getLoadable(tableRowIdsState)- .valueOrThrow();+ const isRowSelectedFamilyState =+ injectFamilyStateWithRecordTableScopeId(isRowSelectedScopeInjector);if (allRowsSelectedStatus === 'none' ||@@ -29,7 +46,14 @@ export const useSelectAllRows = () => {}}},- [],+ [+ allRowsSelectedStatusScopeInjector,+ injectFamilyStateWithRecordTableScopeId,+ injectSelectorSnapshotValueWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ isRowSelectedScopeInjector,+ tableRowIdsScopeInjector,+ ],);return {diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.tsindex d809bcae5bf..c1cf1fd77dd 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRecordTableData.ts@@ -1,25 +1,35 @@import { useRecoilCallback } from 'recoil';import { entityFieldsFamilyState } from '@/object-record/field/states/entityFieldsFamilyState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';import { useResetTableRowSelection } from '@/object-record/record-table/hooks/internal/useResetTableRowSelection';-import { numberOfTableRowsState } from '@/object-record/record-table/states/numberOfTableRowsState';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { isDeeplyEqual } from '~/utils/isDeeplyEqual';-import { tableRowIdsState } from '../../states/tableRowIdsState';-type useSetRecordTableDataProps = {+ recordTableScopeId: string;onEntityCountChange: (entityCount: number) => void;};export const useSetRecordTableData = ({+ recordTableScopeId,onEntityCountChange,}: useSetRecordTableDataProps) => {- const resetTableRowSelection = useResetTableRowSelection();+ const resetTableRowSelection = useResetTableRowSelection(recordTableScopeId);++ const { tableRowIdsScopeInjector, numberOfTableRowsScopeInjector } =+ getRecordTableScopeInjector();++ const {+ injectStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);return useRecoilCallback(({ set, snapshot }) =><T extends { id: string }>(newEntityArray: T[]) => {for (const entity of newEntityArray) {+ // TODO: refactor with scoped state laterconst currentEntity = snapshot.getLoadable(entityFieldsFamilyState(entity.id)).valueOrThrow();@@ -28,19 +38,37 @@ export const useSetRecordTableData = ({set(entityFieldsFamilyState(entity.id), entity);}}- const currentRowIds = snapshot.getLoadable(tableRowIdsState).getValue();+ const currentRowIds = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ tableRowIdsScopeInjector,+ );const entityIds = newEntityArray.map((entity) => entity.id);+ const tableRowIdsState = injectStateWithRecordTableScopeId(+ tableRowIdsScopeInjector,+ );+if (!isDeeplyEqual(currentRowIds, entityIds)) {set(tableRowIdsState, entityIds);}resetTableRowSelection();+ const numberOfTableRowsState = injectStateWithRecordTableScopeId(+ numberOfTableRowsScopeInjector,+ );+set(numberOfTableRowsState, entityIds.length);onEntityCountChange(entityIds.length);},- [onEntityCountChange, resetTableRowSelection],+ [+ injectSnapshotValueWithRecordTableScopeId,+ injectStateWithRecordTableScopeId,+ numberOfTableRowsScopeInjector,+ onEntityCountChange,+ resetTableRowSelection,+ tableRowIdsScopeInjector,+ ],);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRowSelectedState.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRowSelectedState.tsindex aa0d6380c59..647b7fad1ad 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRowSelectedState.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetRowSelectedState.ts@@ -1,8 +1,19 @@import { useRecoilCallback } from 'recoil';-import { isRowSelectedFamilyState } from '../../record-table-row/states/isRowSelectedFamilyState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';-export const useSetRowSelectedState = () =>- useRecoilCallback(({ set }) => (rowId: string, selected: boolean) => {+export const useSetRowSelectedState = (recordTableScopeId: string) => {+ const { isRowSelectedScopeInjector } = getRecordTableScopeInjector();++ const { injectFamilyStateWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableScopeId);++ const isRowSelectedFamilyState = injectFamilyStateWithRecordTableScopeId(+ isRowSelectedScopeInjector,+ );++ return useRecoilCallback(({ set }) => (rowId: string, selected: boolean) => {set(isRowSelectedFamilyState(rowId), selected);});+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetSoftFocusPosition.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetSoftFocusPosition.tsindex 282e6c3443a..6340a993634 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetSoftFocusPosition.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useSetSoftFocusPosition.ts@@ -1,23 +1,60 @@import { useRecoilCallback } from 'recoil';-import { isSoftFocusActiveState } from '../../states/isSoftFocusActiveState';-import { isSoftFocusOnTableCellFamilyState } from '../../states/isSoftFocusOnTableCellFamilyState';-import { softFocusPositionState } from '../../states/softFocusPositionState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';+import { TableCellPosition } from '../../types/TableCellPosition';-export const useSetSoftFocusPosition = () =>- useRecoilCallback(({ set, snapshot }) => {- return (newPosition: TableCellPosition) => {- const currentPosition = snapshot- .getLoadable(softFocusPositionState)- .valueOrThrow();+export const useSetSoftFocusPosition = (recordTableScopeId: string) => {+ const {+ softFocusPositionScopeInjector,+ isSoftFocusActiveScopeInjector,+ isSoftFocusOnTableCellScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates(recordTableScopeId);++ return useRecoilCallback(+ ({ set, snapshot }) => {+ return (newPosition: TableCellPosition) => {+ const currentPosition = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ softFocusPositionScopeInjector,+ );++ const isSoftFocusActiveState = injectStateWithRecordTableScopeId(+ isSoftFocusActiveScopeInjector,+ );++ const isSoftFocusOnTableCellFamilyState =+ injectFamilyStateWithRecordTableScopeId(+ isSoftFocusOnTableCellScopeInjector,+ );++ const softFocusPositionState = injectStateWithRecordTableScopeId(+ softFocusPositionScopeInjector,+ );- set(isSoftFocusActiveState, true);+ set(isSoftFocusActiveState, true);- set(isSoftFocusOnTableCellFamilyState(currentPosition), false);+ set(isSoftFocusOnTableCellFamilyState(currentPosition), false);- set(softFocusPositionState, newPosition);+ set(softFocusPositionState, newPosition);- set(isSoftFocusOnTableCellFamilyState(newPosition), true);- };- }, []);+ set(isSoftFocusOnTableCellFamilyState(newPosition), true);+ };+ },+ [+ injectFamilyStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectStateWithRecordTableScopeId,+ isSoftFocusActiveScopeInjector,+ isSoftFocusOnTableCellScopeInjector,+ softFocusPositionScopeInjector,+ ],+ );+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useUpsertRecordTableItem.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useUpsertRecordTableItem.tsindex bacbb1ae9df..3f7e411f5e8 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useUpsertRecordTableItem.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useUpsertRecordTableItem.ts@@ -3,8 +3,9 @@ import { useRecoilCallback } from 'recoil';import { entityFieldsFamilyState } from '@/object-record/field/states/entityFieldsFamilyState';import { isDeeplyEqual } from '~/utils/isDeeplyEqual';-export const useUpsertRecordTableItem = () =>- useRecoilCallback(+// TODO: refactor with scoped state later+export const useUpsertRecordTableItem = () => {+ return useRecoilCallback(({ set, snapshot }) =><T extends { id: string }>(entity: T) => {const currentEntity = snapshot@@ -17,3 +18,4 @@ export const useUpsertRecordTableItem = () =>},[],);+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.tsindex 410b0741c7a..e9136c99a13 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts@@ -1,8 +1,9 @@import { useRecoilCallback, useSetRecoilState } from 'recoil';import { Key } from 'ts-key-enum';+import { useGetIsSomeCellInEditMode } from '@/object-record/record-table/hooks/internal/useGetIsSomeCellInEditMode';import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';-import { onColumnsChangeScopedState } from '@/object-record/record-table/states/onColumnsChangeScopedState';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';@@ -10,10 +11,7 @@ import { getScopedStateDeprecated } from '@/ui/utilities/recoil-scope/utils/getSimport { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';import { FieldMetadata } from '../../field/types/FieldMetadata';-import { numberOfTableRowsState } from '../states/numberOfTableRowsState';-import { onEntityCountChangeScopedState } from '../states/onEntityCountChange';-import { numberOfTableColumnsScopedSelector } from '../states/selectors/numberOfTableColumnsScopedSelector';-import { softFocusPositionState } from '../states/softFocusPositionState';+import { onEntityCountChangeScopedState } from '../states/onEntityCountChangeScopedState';import { ColumnDefinition } from '../types/ColumnDefinition';import { TableHotkeyScope } from '../types/TableHotkeyScope';@@ -38,43 +36,71 @@ export const useRecordTable = (props?: useRecordTableProps) => {);const {- availableTableColumnsState,- tableFiltersState,- tableSortsState,- tableColumnsState,- objectMetadataConfigState,- onEntityCountChangeState,- } = useRecordTableScopedStates({- customRecordTableScopeId: scopeId,- });+ injectStateWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ injectSelectorSnapshotValueWithRecordTableScopeId,+ } = useRecordTableScopedStates(scopeId);++ const {+ availableTableColumnsScopeInjector,+ tableFiltersScopeInjector,+ tableSortsScopeInjector,+ tableColumnsScopeInjector,+ objectMetadataConfigScopeInjector,+ onEntityCountScopeInjector,+ softFocusPositionScopeInjector,+ numberOfTableRowsScopeInjector,+ numberOfTableColumnsScopeInjector,+ onColumnsChangeScopeInjector,+ isRecordTableInitialLoadingScopeInjector,+ tableLastRowVisibleScopeInjector,+ } = getRecordTableScopeInjector();const setAvailableTableColumns = useSetRecoilState(- availableTableColumnsState,+ injectStateWithRecordTableScopeId(availableTableColumnsScopeInjector),+ );++ const setOnEntityCountChange = useSetRecoilState(+ injectStateWithRecordTableScopeId(onEntityCountScopeInjector),+ );+ const setTableFilters = useSetRecoilState(+ injectStateWithRecordTableScopeId(tableFiltersScopeInjector),+ );+ const setObjectMetadataConfig = useSetRecoilState(+ injectStateWithRecordTableScopeId(objectMetadataConfigScopeInjector),+ );++ const setTableSorts = useSetRecoilState(+ injectStateWithRecordTableScopeId(tableSortsScopeInjector),+ );++ const setTableColumns = useSetRecoilState(+ injectStateWithRecordTableScopeId(tableColumnsScopeInjector),);- const setOnEntityCountChange = useSetRecoilState(onEntityCountChangeState);- const setTableFilters = useSetRecoilState(tableFiltersState);- const setObjectMetadataConfig = useSetRecoilState(objectMetadataConfigState);+ const setOnColumnsChange = useSetRecoilState(+ injectStateWithRecordTableScopeId(onColumnsChangeScopeInjector),+ );- const setTableSorts = useSetRecoilState(tableSortsState);+ const setIsRecordTableInitialLoading = useSetRecoilState(+ injectStateWithRecordTableScopeId(isRecordTableInitialLoadingScopeInjector),+ );- const setTableColumns = useSetRecoilState(tableColumnsState);+ const setRecordTableLastRowVisible = useSetRecoilState(+ injectStateWithRecordTableScopeId(tableLastRowVisibleScopeInjector),+ );const onColumnsChange = useRecoilCallback(({ snapshot }) =>(columns: ColumnDefinition<FieldMetadata>[]) => {- const onColumnsChangeState = getScopedStateDeprecated(- onColumnsChangeScopedState,- scopeId,- );- const onColumnsChange = getSnapshotValue(+ const onColumnsChange = injectSnapshotValueWithRecordTableScopeId(snapshot,- onColumnsChangeState,+ onColumnsChangeScopeInjector,);onColumnsChange?.(columns);},- [scopeId],+ [injectSnapshotValueWithRecordTableScopeId, onColumnsChangeScopeInjector],);const onEntityCountChange = useRecoilCallback(@@ -94,24 +120,28 @@ export const useRecordTable = (props?: useRecordTableProps) => {[scopeId],);- const setRecordTableData = useSetRecordTableData({ onEntityCountChange });+ const setRecordTableData = useSetRecordTableData({+ recordTableScopeId: scopeId,+ onEntityCountChange,+ });- const leaveTableFocus = useLeaveTableFocus();+ const leaveTableFocus = useLeaveTableFocus(scopeId);- const setRowSelectedState = useSetRowSelectedState();+ const setRowSelectedState = useSetRowSelectedState(scopeId);- const resetTableRowSelection = useResetTableRowSelection();+ const resetTableRowSelection = useResetTableRowSelection(scopeId);const upsertRecordTableItem = useUpsertRecordTableItem();- const setSoftFocusPosition = useSetSoftFocusPosition();+ const setSoftFocusPosition = useSetSoftFocusPosition(scopeId);const moveUp = useRecoilCallback(({ snapshot }) =>() => {- const softFocusPosition = snapshot- .getLoadable(softFocusPositionState)- .valueOrThrow();+ const softFocusPosition = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ softFocusPositionScopeInjector,+ );let newRowNumber = softFocusPosition.row - 1;@@ -124,19 +154,25 @@ export const useRecordTable = (props?: useRecordTableProps) => {row: newRowNumber,});},- [setSoftFocusPosition],+ [+ injectSnapshotValueWithRecordTableScopeId,+ setSoftFocusPosition,+ softFocusPositionScopeInjector,+ ],);const moveDown = useRecoilCallback(({ snapshot }) =>() => {- const softFocusPosition = snapshot- .getLoadable(softFocusPositionState)- .valueOrThrow();+ const softFocusPosition = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ softFocusPositionScopeInjector,+ );- const numberOfTableRows = snapshot- .getLoadable(numberOfTableRowsState)- .valueOrThrow();+ const numberOfTableRows = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ numberOfTableRowsScopeInjector,+ );let newRowNumber = softFocusPosition.row + 1;@@ -149,24 +185,32 @@ export const useRecordTable = (props?: useRecordTableProps) => {row: newRowNumber,});},- [setSoftFocusPosition],+ [+ injectSnapshotValueWithRecordTableScopeId,+ numberOfTableRowsScopeInjector,+ setSoftFocusPosition,+ softFocusPositionScopeInjector,+ ],);const moveRight = useRecoilCallback(({ snapshot }) =>() => {- const softFocusPosition = snapshot- .getLoadable(softFocusPositionState)- .valueOrThrow();-- const numberOfTableColumns = snapshot- .getLoadable(numberOfTableColumnsScopedSelector(scopeId))- .valueOrThrow();+ const softFocusPosition = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ softFocusPositionScopeInjector,+ );- const numberOfTableRows = snapshot- .getLoadable(numberOfTableRowsState)- .valueOrThrow();+ const numberOfTableColumns =+ injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ numberOfTableColumnsScopeInjector,+ );+ const numberOfTableRows = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ numberOfTableRowsScopeInjector,+ );const currentColumnNumber = softFocusPosition.column;const currentRowNumber = softFocusPosition.row;@@ -197,19 +241,29 @@ export const useRecordTable = (props?: useRecordTableProps) => {});}},- [scopeId, setSoftFocusPosition],+ [+ injectSelectorSnapshotValueWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ numberOfTableColumnsScopeInjector,+ numberOfTableRowsScopeInjector,+ setSoftFocusPosition,+ softFocusPositionScopeInjector,+ ],);const moveLeft = useRecoilCallback(({ snapshot }) =>() => {- const softFocusPosition = snapshot- .getLoadable(softFocusPositionState)- .valueOrThrow();+ const softFocusPosition = injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ softFocusPositionScopeInjector,+ );- const numberOfTableColumns = snapshot- .getLoadable(numberOfTableColumnsScopedSelector(scopeId))- .valueOrThrow();+ const numberOfTableColumns =+ injectSelectorSnapshotValueWithRecordTableScopeId(+ snapshot,+ numberOfTableColumnsScopeInjector,+ );const currentColumnNumber = softFocusPosition.column;const currentRowNumber = softFocusPosition.row;@@ -238,11 +292,17 @@ export const useRecordTable = (props?: useRecordTableProps) => {});}},- [scopeId, setSoftFocusPosition],+ [+ injectSelectorSnapshotValueWithRecordTableScopeId,+ injectSnapshotValueWithRecordTableScopeId,+ numberOfTableColumnsScopeInjector,+ setSoftFocusPosition,+ softFocusPositionScopeInjector,+ ],);const useMapKeyboardToSoftFocus = () => {- const disableSoftFocus = useDisableSoftFocus();+ const disableSoftFocus = useDisableSoftFocus(scopeId);const setHotkeyScope = useSetHotkeyScope();useScopedHotkeys(@@ -295,7 +355,9 @@ export const useRecordTable = (props?: useRecordTableProps) => {);};- const { selectAllRows } = useSelectAllRows();+ const { selectAllRows } = useSelectAllRows(scopeId);++ const getIsSomeCellInEditMode = useGetIsSomeCellInEditMode(scopeId);return {scopeId,@@ -317,5 +379,10 @@ export const useRecordTable = (props?: useRecordTableProps) => {moveUp,useMapKeyboardToSoftFocus,selectAllRows,+ setOnColumnsChange,+ setIsRecordTableInitialLoading,+ setRecordTableLastRowVisible,+ setSoftFocusPosition,+ getIsSomeCellInEditMode,};};diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useTableColumns.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useTableColumns.tsindex b80e8450d8b..1bdc0cca0c8 100644--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useTableColumns.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useTableColumns.ts@@ -4,6 +4,7 @@ import { useRecoilValue } from 'recoil';import { FieldMetadata } from '@/object-record/field/types/FieldMetadata';import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';import { useMoveViewColumns } from '@/views/hooks/useMoveViewColumns';@@ -25,12 +26,27 @@ export const useTableColumns = (props?: useRecordTableProps) => {});const {- availableTableColumnsState,- tableColumnsState,- visibleTableColumnsSelector,- } = useRecordTableScopedStates({- customRecordTableScopeId: scopeId,- });+ injectStateWithRecordTableScopeId,+ injectSelectorWithRecordTableScopeId,+ } = useRecordTableScopedStates(scopeId);++ const {+ availableTableColumnsScopeInjector,+ tableColumnsScopeInjector,+ visibleTableColumnsScopeInjector,+ } = getRecordTableScopeInjector();++ const availableTableColumnsState = injectStateWithRecordTableScopeId(+ availableTableColumnsScopeInjector,+ );++ const tableColumnsState = injectStateWithRecordTableScopeId(+ tableColumnsScopeInjector,+ );++ const visibleTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ visibleTableColumnsScopeInjector,+ );const availableTableColumns = useRecoilValue(availableTableColumnsState);diff --git a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownButton.tsx b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownButton.tsxindex 842d6b69868..11736f506ad 100644--- a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownButton.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownButton.tsx@@ -3,9 +3,9 @@ import { StyledHeaderDropdownButton } from '@/ui/layout/dropdown/components/Stylimport { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';export const TableOptionsDropdownButton = () => {- const { isDropdownOpen, toggleDropdown } = useDropdown({- dropdownScopeId: TableOptionsDropdownId,- });+ const { isDropdownOpen, toggleDropdown } = useDropdown(+ TableOptionsDropdownId,+ );return (<StyledHeaderDropdownButtondiff --git a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsxindex e28f1b5be1f..9d17d96428e 100644--- a/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/options/components/TableOptionsDropdownContent.tsx@@ -3,6 +3,8 @@ import { OnDragEndResponder } from '@hello-pangea/dnd';import { useRecoilValue } from 'recoil';import { Key } from 'ts-key-enum';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { IconChevronLeft, IconFileImport, IconTag } from '@/ui/display/icon';import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';import { DropdownMenuInput } from '@/ui/layout/dropdown/components/DropdownMenuInput';@@ -15,7 +17,6 @@ import { ViewFieldsVisibilityDropdownSection } from '@/views/components/ViewFielimport { useViewScopedStates } from '@/views/hooks/internal/useViewScopedStates';import { useViewBar } from '@/views/hooks/useViewBar';-import { useRecordTableScopedStates } from '../../hooks/internal/useRecordTableScopedStates';import { useTableColumns } from '../../hooks/useTableColumns';import { TableOptionsHotkeyScope } from '../../types/TableOptionsHotkeyScope';@@ -41,8 +42,19 @@ export const TableOptionsDropdownContent = ({const viewEditInputRef = useRef<HTMLInputElement>(null);- const { hiddenTableColumnsSelector, visibleTableColumnsSelector } =- useRecordTableScopedStates({ customRecordTableScopeId: recordTableId });+ const { hiddenTableColumnsScopeInjector, visibleTableColumnsScopeInjector } =+ getRecordTableScopeInjector();++ const { injectSelectorWithRecordTableScopeId } =+ useRecordTableScopedStates(recordTableId);++ const hiddenTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ hiddenTableColumnsScopeInjector,+ );++ const visibleTableColumnsSelector = injectSelectorWithRecordTableScopeId(+ visibleTableColumnsScopeInjector,+ );const hiddenTableColumns = useRecoilValue(hiddenTableColumnsSelector);const visibleTableColumns = useRecoilValue(visibleTableColumnsSelector);diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCell.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCell.tsxindex e4945a2e4f7..42503e53b2d 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCell.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCell.tsx@@ -8,7 +8,7 @@ import { useTableCell } from '../hooks/useTableCell';import { TableCellContainer } from './RecordTableCellContainer';-export const TableCell = ({+export const RecordTableCell = ({customHotkeyScope,}: {customHotkeyScope: HotkeyScope;diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellButton.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellButton.tsxindex 1cdc93b8ffc..fb528c947a5 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellButton.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellButton.tsx@@ -9,12 +9,15 @@ const StyledEditButtonContainer = styled(motion.div)`right: 5px;`;-type TableCellButtonProps = {+type RecordTableCellButtonProps = {onClick?: () => void;Icon: IconComponent;};-export const TableCellButton = ({ onClick, Icon }: TableCellButtonProps) => (+export const RecordTableCellButton = ({+ onClick,+ Icon,+}: RecordTableCellButtonProps) => (<StyledEditButtonContainerinitial={{ opacity: 0 }}animate={{ opacity: 1 }}diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsxindex 31cb5279d5a..a76f8bf125f 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx@@ -4,7 +4,7 @@ import styled from '@emotion/styled';import { useGetButtonIcon } from '@/object-record/field/hooks/useGetButtonIcon';import { useIsFieldEmpty } from '@/object-record/field/hooks/useIsFieldEmpty';import { useIsFieldInputOnly } from '@/object-record/field/hooks/useIsFieldInputOnly';-import { useGetIsSomeCellInEditMode } from '@/object-record/record-table/hooks/internal/useGetIsSomeCellInEditMode';+import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';import { IconArrowUpRight } from '@/ui/display/icon';import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';@@ -17,10 +17,10 @@ import { useMoveSoftFocusToCurrentCellOnHover } from '../hooks/useMoveSoftFocusTimport { useSetSoftFocusOnCurrentTableCell } from '../hooks/useSetSoftFocusOnCurrentTableCell';import { useTableCell } from '../hooks/useTableCell';-import { TableCellButton } from './RecordTableCellButton';-import { TableCellDisplayMode } from './RecordTableCellDisplayMode';-import { TableCellEditMode } from './RecordTableCellEditMode';-import { TableCellSoftFocusMode } from './RecordTableCellSoftFocusMode';+import { RecordTableCellButton } from './RecordTableCellButton';+import { RecordTableCellDisplayMode } from './RecordTableCellDisplayMode';+import { RecordTableCellEditMode } from './RecordTableCellEditMode';+import { RecordTableCellSoftFocusMode } from './RecordTableCellSoftFocusMode';const StyledCellBaseContainer = styled.div`align-items: center;@@ -57,7 +57,7 @@ export const TableCellContainer = ({}: TableCellContainerProps) => {const { isCurrentTableCellInEditMode } = useCurrentTableCellEditMode();- const getIsSomeCellInEditMode = useGetIsSomeCellInEditMode();+ const { getIsSomeCellInEditMode } = useRecordTable();const [isHovered, setIsHovered] = useState(false);@@ -116,29 +116,35 @@ export const TableCellContainer = ({onMouseLeave={handleContainerMouseLeave}>{isCurrentTableCellInEditMode ? (- <TableCellEditMode+ <RecordTableCellEditModeeditModeHorizontalAlign={editModeHorizontalAlign}editModeVerticalPosition={editModeVerticalPosition}>{editModeContent}- </TableCellEditMode>+ </RecordTableCellEditMode>) : hasSoftFocus ? (<>{showButton && (- <TableCellButton onClick={handleButtonClick} Icon={buttonIcon} />+ <RecordTableCellButton+ onClick={handleButtonClick}+ Icon={buttonIcon}+ />)}- <TableCellSoftFocusMode>+ <RecordTableCellSoftFocusMode>{editModeContentOnly ? editModeContent : nonEditModeContent}- </TableCellSoftFocusMode>+ </RecordTableCellSoftFocusMode></>) : (<>{showButton && (- <TableCellButton onClick={handleButtonClick} Icon={buttonIcon} />+ <RecordTableCellButton+ onClick={handleButtonClick}+ Icon={buttonIcon}+ />)}- <TableCellDisplayMode>+ <RecordTableCellDisplayMode>{editModeContentOnly ? editModeContent : nonEditModeContent}- </TableCellDisplayMode>+ </RecordTableCellDisplayMode></>)}</StyledCellBaseContainer>diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayContainer.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayContainer.tsxindex c6d156817f2..4a1c1d7875a 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayContainer.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayContainer.tsx@@ -34,7 +34,7 @@ const StyledEditableCellDisplayModeInnerContainer = styled.div`width: 100%;`;-export const TableCellDisplayContainer = ({+export const RecordTableCellDisplayContainer = ({children,softFocus,onClick,diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayMode.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayMode.tsxindex ebd98aa02fc..a296132c746 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayMode.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellDisplayMode.tsx@@ -3,9 +3,9 @@ import { useIsFieldInputOnly } from '@/object-record/field/hooks/useIsFieldInputimport { useSetSoftFocusOnCurrentTableCell } from '../hooks/useSetSoftFocusOnCurrentTableCell';import { useTableCell } from '../hooks/useTableCell';-import { TableCellDisplayContainer } from './RecordTableCellDisplayContainer';+import { RecordTableCellDisplayContainer } from './RecordTableCellDisplayContainer';-export const TableCellDisplayMode = ({+export const RecordTableCellDisplayMode = ({children,}: React.PropsWithChildren<unknown>) => {const setSoftFocusOnCurrentCell = useSetSoftFocusOnCurrentTableCell();@@ -23,8 +23,8 @@ export const TableCellDisplayMode = ({};return (- <TableCellDisplayContainer onClick={handleClick}>+ <RecordTableCellDisplayContainer onClick={handleClick}>{children}- </TableCellDisplayContainer>+ </RecordTableCellDisplayContainer>);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditButton.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditButton.tsxindex 1cdc93b8ffc..69887f77497 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditButton.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditButton.tsx@@ -9,12 +9,15 @@ const StyledEditButtonContainer = styled(motion.div)`right: 5px;`;-type TableCellButtonProps = {+type RecordTableCellEditButtonProps = {onClick?: () => void;Icon: IconComponent;};-export const TableCellButton = ({ onClick, Icon }: TableCellButtonProps) => (+export const RecordTableCellEditButton = ({+ onClick,+ Icon,+}: RecordTableCellEditButtonProps) => (<StyledEditButtonContainerinitial={{ opacity: 0 }}animate={{ opacity: 1 }}diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditMode.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditMode.tsxindex df0fd5e4402..b0d6ef6c0a8 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditMode.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditMode.tsx@@ -1,7 +1,7 @@import { ReactElement } from 'react';import styled from '@emotion/styled';-const StyledEditableCellEditModeContainer = styled.div<TableCellEditModeProps>`+const StyledEditableCellEditModeContainer = styled.div<RecordTableCellEditModeProps>`align-items: center;display: flex;min-width: 200px;@@ -9,7 +9,7 @@ const StyledEditableCellEditModeContainer = styled.div<TableCellEditModeProps>`z-index: 1;`;-export type TableCellEditModeProps = {+export type RecordTableCellEditModeProps = {children: ReactElement;transparent?: boolean;maxContentWidth?: number;@@ -18,11 +18,11 @@ export type TableCellEditModeProps = {initialValue?: string;};-export const TableCellEditMode = ({+export const RecordTableCellEditMode = ({editModeHorizontalAlign,editModeVerticalPosition,children,-}: TableCellEditModeProps) => (+}: RecordTableCellEditModeProps) => (<StyledEditableCellEditModeContainerdata-testid="editable-cell-edit-mode-container"editModeHorizontalAlign={editModeHorizontalAlign}diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsxindex 8ab2975806a..2d105d8943c 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx@@ -9,13 +9,13 @@ import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritinimport { TableHotkeyScope } from '../../types/TableHotkeyScope';import { useTableCell } from '../hooks/useTableCell';-import { TableCellDisplayContainer } from './RecordTableCellDisplayContainer';+import { RecordTableCellDisplayContainer } from './RecordTableCellDisplayContainer';-type TableCellSoftFocusModeProps = PropsWithChildren<unknown>;+type RecordTableCellSoftFocusModeProps = PropsWithChildren<unknown>;-export const TableCellSoftFocusMode = ({+export const RecordTableCellSoftFocusMode = ({children,-}: TableCellSoftFocusModeProps) => {+}: RecordTableCellSoftFocusModeProps) => {const { openTableCell } = useTableCell();const isFieldInputOnly = useIsFieldInputOnly();@@ -95,12 +95,12 @@ export const TableCellSoftFocusMode = ({};return (- <TableCellDisplayContainer+ <RecordTableCellDisplayContaineronClick={handleClick}softFocusscrollRef={scrollRef}>{children}- </TableCellDisplayContainer>+ </RecordTableCellDisplayContainer>);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useCurrentTableCellEditMode.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useCurrentTableCellEditMode.tsindex f446d2f4f74..2bc67d73746 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useCurrentTableCellEditMode.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useCurrentTableCellEditMode.ts@@ -1,16 +1,30 @@import { useCallback } from 'react';import { useRecoilState } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';+import { useMoveEditModeToTableCellPosition } from '../../hooks/internal/useMoveEditModeToCellPosition';-import { isTableCellInEditModeFamilyState } from '../../states/isTableCellInEditModeFamilyState';import { useCurrentTableCellPosition } from './useCurrentCellPosition';export const useCurrentTableCellEditMode = () => {- const moveEditModeToTableCellPosition = useMoveEditModeToTableCellPosition();+ const { scopeId } = useRecordTable();++ const moveEditModeToTableCellPosition =+ useMoveEditModeToTableCellPosition(scopeId);const currentTableCellPosition = useCurrentTableCellPosition();+ const { isTableCellInEditModeScopeInjector } = getRecordTableScopeInjector();++ const { injectFamilyStateWithRecordTableScopeId } =+ useRecordTableScopedStates();++ const isTableCellInEditModeFamilyState =+ injectFamilyStateWithRecordTableScopeId(isTableCellInEditModeScopeInjector);+const [isCurrentTableCellInEditMode] = useRecoilState(isTableCellInEditModeFamilyState(currentTableCellPosition),);diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useIsSoftFocusOnCurrentTableCell.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useIsSoftFocusOnCurrentTableCell.tsindex ac6c3541575..058b377bcb3 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useIsSoftFocusOnCurrentTableCell.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useIsSoftFocusOnCurrentTableCell.ts@@ -1,14 +1,24 @@import { useRecoilValue } from 'recoil';-import { isSoftFocusOnTableCellFamilyState } from '../../states/isSoftFocusOnTableCellFamilyState';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { useCurrentTableCellPosition } from './useCurrentCellPosition';export const useIsSoftFocusOnCurrentTableCell = () => {const currentTableCellPosition = useCurrentTableCellPosition();+ const { isSoftFocusOnTableCellScopeInjector } = getRecordTableScopeInjector();++ const { injectFamilyStateWithRecordTableScopeId } =+ useRecordTableScopedStates();++ const isSoftFocusActiveFamilyState = injectFamilyStateWithRecordTableScopeId(+ isSoftFocusOnTableCellScopeInjector,+ );+const isSoftFocusOnTableCell = useRecoilValue(- isSoftFocusOnTableCellFamilyState(currentTableCellPosition),+ isSoftFocusActiveFamilyState(currentTableCellPosition),);return isSoftFocusOnTableCell;diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.tsindex 31a9320d73f..95b35582761 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts@@ -1,9 +1,9 @@import { useRecoilCallback } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { currentHotkeyScopeState } from '@/ui/utilities/hotkey/states/internal/currentHotkeyScopeState';-import { currentTableCellInEditModePositionState } from '../../states/currentTableCellInEditModePositionState';-import { isTableCellInEditModeFamilyState } from '../../states/isTableCellInEditModeFamilyState';import { TableHotkeyScope } from '../../types/TableHotkeyScope';import { useSetSoftFocusOnCurrentTableCell } from './useSetSoftFocusOnCurrentTableCell';@@ -11,12 +11,27 @@ import { useSetSoftFocusOnCurrentTableCell } from './useSetSoftFocusOnCurrentTabexport const useMoveSoftFocusToCurrentCellOnHover = () => {const setSoftFocusOnCurrentTableCell = useSetSoftFocusOnCurrentTableCell();+ const {+ currentTableCellInEditModePositionScopeInjector,+ isTableCellInEditModeScopeInjector,+ } = getRecordTableScopeInjector();++ const {+ injectSnapshotValueWithRecordTableScopeId,+ injectFamilyStateWithRecordTableScopeId,+ } = useRecordTableScopedStates();++ const isTableCellInEditModeFamilyState =+ injectFamilyStateWithRecordTableScopeId(isTableCellInEditModeScopeInjector);+return useRecoilCallback(({ snapshot }) =>() => {- const currentTableCellInEditModePosition = snapshot- .getLoadable(currentTableCellInEditModePositionState)- .valueOrThrow();+ const currentTableCellInEditModePosition =+ injectSnapshotValueWithRecordTableScopeId(+ snapshot,+ currentTableCellInEditModePositionScopeInjector,+ );const isSomeCellInEditMode = snapshot.getLoadable(isTableCellInEditModeFamilyState(currentTableCellInEditModePosition),@@ -38,6 +53,11 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {setSoftFocusOnCurrentTableCell();}},- [setSoftFocusOnCurrentTableCell],+ [+ currentTableCellInEditModePositionScopeInjector,+ injectSnapshotValueWithRecordTableScopeId,+ isTableCellInEditModeFamilyState,+ setSoftFocusOnCurrentTableCell,+ ],);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useSetSoftFocusOnCurrentTableCell.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useSetSoftFocusOnCurrentTableCell.tsindex 8c5fcd1d3d1..0ad1b318348 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useSetSoftFocusOnCurrentTableCell.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useSetSoftFocusOnCurrentTableCell.ts@@ -1,15 +1,24 @@import { useRecoilCallback } from 'recoil';+import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';-import { useSetSoftFocusPosition } from '../../hooks/internal/useSetSoftFocusPosition';-import { isSoftFocusActiveState } from '../../states/isSoftFocusActiveState';import { TableHotkeyScope } from '../../types/TableHotkeyScope';import { useCurrentTableCellPosition } from './useCurrentCellPosition';export const useSetSoftFocusOnCurrentTableCell = () => {- const setSoftFocusPosition = useSetSoftFocusPosition();+ const { setSoftFocusPosition } = useRecordTable();++ const { isSoftFocusActiveScopeInjector } = getRecordTableScopeInjector();++ const { injectStateWithRecordTableScopeId } = useRecordTableScopedStates();++ const isSoftFocusActiveState = injectStateWithRecordTableScopeId(+ isSoftFocusActiveScopeInjector,+ );const currentTableCellPosition = useCurrentTableCellPosition();@@ -24,6 +33,11 @@ export const useSetSoftFocusOnCurrentTableCell = () => {setHotkeyScope(TableHotkeyScope.TableSoftFocus);},- [setHotkeyScope, currentTableCellPosition, setSoftFocusPosition],+ [+ setSoftFocusPosition,+ currentTableCellPosition,+ isSoftFocusActiveState,+ setHotkeyScope,+ ],);};diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useTableCell.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useTableCell.tsindex 166440af687..2f40ff1e35f 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useTableCell.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useTableCell.ts@@ -7,6 +7,8 @@ import { useIsFieldEmpty } from '@/object-record/field/hooks/useIsFieldEmpty';import { entityFieldInitialValueFamilyState } from '@/object-record/field/states/entityFieldInitialValueFamilyState';import { FieldInitialValue } from '@/object-record/field/types/FieldInitialValue';import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { useDragSelect } from '@/ui/utilities/drag-select/hooks/useDragSelect';import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';@@ -23,9 +25,15 @@ const DEFAULT_CELL_SCOPE: HotkeyScope = {};export const useTableCell = () => {- const { objectMetadataConfigState } = useRecordTableScopedStates();+ const { scopeId: recordTableScopeId } = useRecordTable();- const objectMetadataConfig = useRecoilValue(objectMetadataConfigState);+ const { objectMetadataConfigScopeInjector } = getRecordTableScopeInjector();++ const { injectStateWithRecordTableScopeId } = useRecordTableScopedStates();++ const objectMetadataConfig = useRecoilValue(+ injectStateWithRecordTableScopeId(objectMetadataConfigScopeInjector),+ );const basePathToShowPage = objectMetadataConfig?.basePathToShowPage;@@ -33,7 +41,8 @@ export const useTableCell = () => {const setHotkeyScope = useSetHotkeyScope();const { setDragSelectionStartEnabled } = useDragSelect();- const closeCurrentTableCellInEditMode = useCloseCurrentTableCellInEditMode();+ const closeCurrentTableCellInEditMode =+ useCloseCurrentTableCellInEditMode(recordTableScopeId);const customCellHotkeyScope = useContext(CellHotkeyScopeContext);diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/hooks/useCurrentRowSelected.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/hooks/useCurrentRowSelected.tsindex dddb5a4645a..3d278ac97d6 100644--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/hooks/useCurrentRowSelected.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/hooks/useCurrentRowSelected.ts@@ -1,13 +1,26 @@import { useContext } from 'react';-import { useRecoilCallback, useRecoilState } from 'recoil';+import { useRecoilCallback, useRecoilValue } from 'recoil';++import { useRecordTableScopedStates } from '@/object-record/record-table/hooks/internal/useRecordTableScopedStates';+import { getRecordTableScopeInjector } from '@/object-record/record-table/utils/getRecordTableScopeInjector';import { RowIdContext } from '../../contexts/RowIdContext';-import { isRowSelectedFamilyState } from '../states/isRowSelectedFamilyState';export const useCurrentRowSelected = () => {const currentRowId = useContext(RowIdContext);- const [isRowSelected] = useRecoilState(+ const { isRowSelectedScopeInjector } = getRecordTableScopeInjector();++ const {+ injectFamilyStateWithRecordTableScopeId,+ injectFamilySnapshotValueWithRecordTableScopeId,+ } = useRecordTableScopedStates();++ const isRowSelectedFamilyState = injectFamilyStateWithRecordTableScopeId(+ isRowSelectedScopeInjector,+ );++ const isRowSelected = useRecoilValue(isRowSelectedFamilyState(currentRowId ?? ''),);@@ -16,9 +29,10 @@ export const useCurrentRowSelected = () => {(newSelectedState: boolean) => {if (!currentRowId) return;- const isRowSelected = snapshot- .getLoadable(isRowSelectedFamilyState(currentRowId))- .valueOrThrow();+ const isRowSelected = injectFamilySnapshotValueWithRecordTableScopeId(+ snapshot,+ isRowSelectedScopeInjector,+ )(currentRowId);if (newSelectedState && !isRowSelected) {set(isRowSelectedFamilyState(currentRowId), true);@@ -26,7 +40,12 @@ export const useCurrentRowSelected = () => {set(isRowSelectedFamilyState(currentRowId), false);}},- [currentRowId],+ [+ currentRowId,+ injectFamilySnapshotValueWithRecordTableScopeId,+ isRowSelectedFamilyState,+ isRowSelectedScopeInjector,+ ],);return {diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedFamilyState.tsdeleted file mode 100644index 70ef414b802..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedFamilyState.ts+++ /dev/null@@ -1,6 +0,0 @@-import { atomFamily } from 'recoil';--export const isRowSelectedFamilyState = atomFamily<boolean, string>({- key: 'isRowSelectedFamilyState',- default: false,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.tsnew file mode 100644index 00000000000..8a684cec6dc--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.ts@@ -0,0 +1,9 @@+import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState';++export const isRowSelectedScopedFamilyState = createScopedFamilyState<+ boolean,+ string+>({+ key: 'isRowSelectedFamilyState',+ defaultValue: false,+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/scopes/RecordTableScopeInitEffect.tsx b/packages/twenty-front/src/modules/object-record/record-table/scopes/RecordTableScopeInitEffect.tsxindex e7da03262a9..0e12971a0e4 100644--- a/packages/twenty-front/src/modules/object-record/record-table/scopes/RecordTableScopeInitEffect.tsx+++ b/packages/twenty-front/src/modules/object-record/record-table/scopes/RecordTableScopeInitEffect.tsx@@ -1,8 +1,8 @@import { useEffect } from 'react';-import { useSetRecoilState } from 'recoil';++import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';import { FieldMetadata } from '../../field/types/FieldMetadata';-import { useRecordTableScopedStates } from '../hooks/internal/useRecordTableScopedStates';import { ColumnDefinition } from '../types/ColumnDefinition';type RecordTableScopeInitEffectProps = {@@ -13,9 +13,7 @@ type RecordTableScopeInitEffectProps = {export const RecordTableScopeInitEffect = ({onColumnsChange,}: RecordTableScopeInitEffectProps) => {- const { onColumnsChangeState } = useRecordTableScopedStates();-- const setOnColumnsChange = useSetRecoilState(onColumnsChangeState);+ const { setOnColumnsChange } = useRecordTable();useEffect(() => {setOnColumnsChange(() => onColumnsChange);diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.tsnew file mode 100644index 00000000000..c6560c4b15d--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.ts@@ -0,0 +1,12 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++import { TableCellPosition } from '../types/TableCellPosition';++export const currentTableCellInEditModePositionScopedState =+ createScopedState<TableCellPosition>({+ key: 'currentTableCellInEditModePositionScopedState',+ defaultValue: {+ row: 0,+ column: 1,+ },+ });diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionState.tsdeleted file mode 100644index 1a2d2933f29..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionState.ts+++ /dev/null@@ -1,11 +0,0 @@-import { atom } from 'recoil';--import { TableCellPosition } from '../types/TableCellPosition';--export const currentTableCellInEditModePositionState = atom<TableCellPosition>({- key: 'currentTableCellInEditModePositionState',- default: {- row: 0,- column: 1,- },-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.tsnew file mode 100644index 00000000000..e7637024f97--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.ts@@ -0,0 +1,7 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++export const isRecordTableInitialLoadingScopedState =+ createScopedState<boolean>({+ key: 'isRecordTableInitialLoadingScopedState',+ defaultValue: true,+ });diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingState.tsdeleted file mode 100644index 9186d0f9ebf..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingState.ts+++ /dev/null@@ -1,6 +0,0 @@-import { atom } from 'recoil';--export const isRecordTableInitialLoadingState = atom<boolean>({- key: 'isRecordTableInitialLoadingState',- default: true,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.tsnew file mode 100644index 00000000000..a81b5c1ba96--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.ts@@ -0,0 +1,6 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++export const isSoftFocusActiveScopedState = createScopedState<boolean>({+ key: 'isSoftFocusActiveScopedState',+ defaultValue: false,+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveState.tsdeleted file mode 100644index b823478993a..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveState.ts+++ /dev/null@@ -1,6 +0,0 @@-import { atom } from 'recoil';--export const isSoftFocusActiveState = atom<boolean>({- key: 'isSoftFocusActiveState',- default: false,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellFamilyState.tsdeleted file mode 100644index 931bb410150..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellFamilyState.ts+++ /dev/null@@ -1,11 +0,0 @@-import { atomFamily } from 'recoil';--import { TableCellPosition } from '../types/TableCellPosition';--export const isSoftFocusOnTableCellFamilyState = atomFamily<- boolean,- TableCellPosition->({- key: 'isSoftFocusOnTableCellFamilyState',- default: false,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.tsnew file mode 100644index 00000000000..24fd6769abf--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.ts@@ -0,0 +1,11 @@+import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState';++import { TableCellPosition } from '../types/TableCellPosition';++export const isSoftFocusOnTableCellScopedFamilyState = createScopedFamilyState<+ boolean,+ TableCellPosition+>({+ key: 'isSoftFocusOnTableCellScopedFamilyState',+ defaultValue: false,+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeFamilyState.tsdeleted file mode 100644index 8b10b739683..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeFamilyState.ts+++ /dev/null@@ -1,11 +0,0 @@-import { atomFamily } from 'recoil';--import { TableCellPosition } from '../types/TableCellPosition';--export const isTableCellInEditModeFamilyState = atomFamily<- boolean,- TableCellPosition->({- key: 'isTableCellInEditModeFamilyState',- default: false,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.tsnew file mode 100644index 00000000000..ea9ec0889ba--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.ts@@ -0,0 +1,11 @@+import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState';++import { TableCellPosition } from '../types/TableCellPosition';++export const isTableCellInEditModeScopedFamilyState = createScopedFamilyState<+ boolean,+ TableCellPosition+>({+ key: 'isTableCellInEditModeScopedFamilyState',+ defaultValue: false,+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.tsnew file mode 100644index 00000000000..f7111d95eeb--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.ts@@ -0,0 +1,6 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++export const numberOfTableRowsScopedState = createScopedState<number>({+ key: 'numberOfTableRowsScopedState',+ defaultValue: 0,+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsState.tsdeleted file mode 100644index cc599055172..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsState.ts+++ /dev/null@@ -1,6 +0,0 @@-import { atom } from 'recoil';--export const numberOfTableRowsState = atom<number>({- key: 'numberOfTableRowsState',- default: 0,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChange.ts b/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeScopedState.tssimilarity index 100%rename from packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChange.tsrename to packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeScopedState.tsdiff --git a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.tsnew file mode 100644index 00000000000..06f88bdf5dd--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.ts@@ -0,0 +1,6 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++export const resizeFieldOffsetScopedState = createScopedState<number>({+ key: 'resizeFieldOffsetScopedState',+ defaultValue: 0,+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetState.tsdeleted file mode 100644index 847ebc1c774..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetState.ts+++ /dev/null@@ -1,6 +0,0 @@-import { atom } from 'recoil';--export const resizeFieldOffsetState = atom<number>({- key: 'resizeFieldOffsetState',- default: 0,-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.tsnew file mode 100644index 00000000000..8eb788e21ba--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.ts@@ -0,0 +1,29 @@+import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector';++import { AllRowsSelectedStatus } from '../../types/AllRowSelectedStatus';+import { numberOfTableRowsScopedState } from '../numberOfTableRowsScopedState';++import { selectedRowIdsScopedSelector } from './selectedRowIdsScopedSelector';++export const allRowsSelectedStatusScopedSelector =+ createScopedSelector<AllRowsSelectedStatus>({+ key: 'allRowsSelectedStatusScopedSelector',+ get:+ ({ scopeId }) =>+ ({ get }) => {+ const numberOfRows = get(numberOfTableRowsScopedState({ scopeId }));++ const selectedRowIds = get(selectedRowIdsScopedSelector({ scopeId }));++ const numberOfSelectedRows = selectedRowIds.length;++ const allRowsSelectedStatus =+ numberOfSelectedRows === 0+ ? 'none'+ : numberOfRows === numberOfSelectedRows+ ? 'all'+ : 'some';++ return allRowsSelectedStatus;+ },+ });diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusSelector.tsdeleted file mode 100644index e40cc9c8e45..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusSelector.ts+++ /dev/null@@ -1,26 +0,0 @@-import { selector } from 'recoil';--import { AllRowsSelectedStatus } from '../../types/AllRowSelectedStatus';-import { numberOfTableRowsState } from '../numberOfTableRowsState';--import { selectedRowIdsSelector } from './selectedRowIdsSelector';--export const allRowsSelectedStatusSelector = selector<AllRowsSelectedStatus>({- key: 'allRowsSelectedStatusSelector',- get: ({ get }) => {- const numberOfRows = get(numberOfTableRowsState);-- const selectedRowIds = get(selectedRowIdsSelector);-- const numberOfSelectedRows = selectedRowIds.length;-- const allRowsSelectedStatus =- numberOfSelectedRows === 0- ? 'none'- : numberOfRows === numberOfSelectedRows- ? 'all'- : 'some';-- return allRowsSelectedStatus;- },-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.tsindex 658bf6e3071..a6eabee8d87 100644--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts@@ -1,12 +1,12 @@-import { selectorFamily } from 'recoil';+import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector';import { availableTableColumnsScopedState } from '../availableTableColumnsScopedState';import { tableColumnsScopedState } from '../tableColumnsScopedState';-export const hiddenTableColumnsScopedSelector = selectorFamily({+export const hiddenTableColumnsScopedSelector = createScopedSelector({key: 'hiddenTableColumnsScopedSelector',get:- (scopeId: string) =>+ ({ scopeId }) =>({ get }) => {const columns = get(tableColumnsScopedState({ scopeId }));const columnKeys = columns.map(({ fieldMetadataId }) => fieldMetadataId);diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.tsindex e05138b88e4..1e74626af2b 100644--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts@@ -1,11 +1,11 @@-import { selectorFamily } from 'recoil';+import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector';import { tableColumnsScopedState } from '../tableColumnsScopedState';-export const numberOfTableColumnsScopedSelector = selectorFamily({+export const numberOfTableColumnsScopedSelector = createScopedSelector({key: 'numberOfTableColumnsScopedSelector',get:- (scopeId: string) =>+ ({ scopeId }) =>({ get }) =>get(tableColumnsScopedState({ scopeId })).length,});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.tsnew file mode 100644index 00000000000..5988954c30e--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.ts@@ -0,0 +1,23 @@+import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector';++import { isRowSelectedScopedFamilyState } from '../../record-table-row/states/isRowSelectedScopedFamilyState';+import { tableRowIdsScopedState } from '../tableRowIdsScopedState';++export const selectedRowIdsScopedSelector = createScopedSelector<string[]>({+ key: 'selectedRowIdsScopedSelector',+ get:+ ({ scopeId }) =>+ ({ get }) => {+ const rowIds = get(tableRowIdsScopedState({ scopeId }));++ return rowIds.filter(+ (rowId) =>+ get(+ isRowSelectedScopedFamilyState({+ scopeId,+ familyKey: rowId,+ }),+ ) === true,+ );+ },+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsSelector.tsdeleted file mode 100644index de58b51c4f3..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsSelector.ts+++ /dev/null@@ -1,15 +0,0 @@-import { selector } from 'recoil';--import { isRowSelectedFamilyState } from '../../record-table-row/states/isRowSelectedFamilyState';-import { tableRowIdsState } from '../tableRowIdsState';--export const selectedRowIdsSelector = selector<string[]>({- key: 'selectedRowIdsSelector',- get: ({ get }) => {- const rowIds = get(tableRowIdsState);-- return rowIds.filter(- (rowId) => get(isRowSelectedFamilyState(rowId)) === true,- );- },-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.tsindex d9c47702e37..743d541db97 100644--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts@@ -1,14 +1,13 @@-import { selectorFamily } from 'recoil';-import { FieldMetadata } from '@/object-record/field/types/FieldMetadata';+import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector';import { ColumnDefinition } from '../../types/ColumnDefinition';import { tableColumnsScopedState } from '../tableColumnsScopedState';-export const tableColumnsByKeyScopedSelector = selectorFamily({+export const tableColumnsByKeyScopedSelector = createScopedSelector({key: 'tableColumnsByKeyScopedSelector',get:- (scopeId: string) =>+ ({ scopeId }) =>({ get }) =>get(tableColumnsScopedState({ scopeId })).reduce<Record<string, ColumnDefinition<FieldMetadata>>diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.tsindex 348f371d846..35e57373bbe 100644--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts@@ -1,12 +1,12 @@-import { selectorFamily } from 'recoil';+import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector';import { availableTableColumnsScopedState } from '../availableTableColumnsScopedState';import { tableColumnsScopedState } from '../tableColumnsScopedState';-export const visibleTableColumnsScopedSelector = selectorFamily({+export const visibleTableColumnsScopedSelector = createScopedSelector({key: 'visibleTableColumnsScopedSelector',get:- (scopeId: string) =>+ ({ scopeId }) =>({ get }) => {const columns = get(tableColumnsScopedState({ scopeId }));const availableColumnKeys = get(diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.tsnew file mode 100644index 00000000000..ab46025c291--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.ts@@ -0,0 +1,12 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++import { TableCellPosition } from '../types/TableCellPosition';++export const softFocusPositionScopedState =+ createScopedState<TableCellPosition>({+ key: 'softFocusPositionScopedState',+ defaultValue: {+ row: 0,+ column: 1,+ },+ });diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionState.tsdeleted file mode 100644index 6eca1b4791f..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionState.ts+++ /dev/null@@ -1,11 +0,0 @@-import { atom } from 'recoil';--import { TableCellPosition } from '../types/TableCellPosition';--export const softFocusPositionState = atom<TableCellPosition>({- key: 'softFocusPositionState',- default: {- row: 0,- column: 1,- },-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.tsnew file mode 100644index 00000000000..79d5c2dc324--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.ts@@ -0,0 +1,6 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++export const tableRowIdsScopedState = createScopedState<string[]>({+ key: 'tableRowIdsScopedState',+ defaultValue: [],+});diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsState.tsdeleted file mode 100644index e7832f4090f..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsState.ts+++ /dev/null@@ -1,6 +0,0 @@-import { atom } from 'recoil';--export const tableRowIdsState = atom<string[]>({- key: 'tableRowIdsState',- default: [],-});diff --git a/packages/twenty-front/src/modules/object-record/record-table/utils/getRecordTableScopeInjector.ts b/packages/twenty-front/src/modules/object-record/record-table/utils/getRecordTableScopeInjector.tsnew file mode 100644index 00000000000..9f02312d254--- /dev/null+++ b/packages/twenty-front/src/modules/object-record/record-table/utils/getRecordTableScopeInjector.ts@@ -0,0 +1,145 @@+import { isRowSelectedScopedFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState';+import { currentTableCellInEditModePositionScopedState } from '@/object-record/record-table/states/currentTableCellInEditModePositionScopedState';+import { isRecordTableInitialLoadingScopedState } from '@/object-record/record-table/states/isRecordTableInitialLoadingScopedState';+import { isSoftFocusActiveScopedState } from '@/object-record/record-table/states/isSoftFocusActiveScopedState';+import { isSoftFocusOnTableCellScopedFamilyState } from '@/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState';+import { isTableCellInEditModeScopedFamilyState } from '@/object-record/record-table/states/isTableCellInEditModeScopedFamilyState';+import { numberOfTableRowsScopedState } from '@/object-record/record-table/states/numberOfTableRowsScopedState';+import { objectMetadataConfigScopedState } from '@/object-record/record-table/states/objectMetadataConfigScopedState';+import { resizeFieldOffsetScopedState } from '@/object-record/record-table/states/resizeFieldOffsetScopedState';+import { allRowsSelectedStatusScopedSelector } from '@/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector';+import { numberOfTableColumnsScopedSelector } from '@/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector';+import { selectedRowIdsScopedSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsScopedSelector';+import { softFocusPositionScopedState } from '@/object-record/record-table/states/softFocusPositionScopedState';+import { tableLastRowVisibleScopedState } from '@/object-record/record-table/states/tableLastRowVisibleScopedState';+import { tableRowIdsScopedState } from '@/object-record/record-table/states/tableRowIdsScopedState';+import { getFamilyScopeInjector } from '@/ui/utilities/recoil-scope/utils/getFamilyScopeInjector';+import { getScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector';+import { getSelectorScopeInjector } from '@/ui/utilities/recoil-scope/utils/getSelectorScopeInjector';++import { availableTableColumnsScopedState } from '../states/availableTableColumnsScopedState';+import { onColumnsChangeScopedState } from '../states/onColumnsChangeScopedState';+import { onEntityCountChangeScopedState } from '../states/onEntityCountChangeScopedState';+import { hiddenTableColumnsScopedSelector } from '../states/selectors/hiddenTableColumnsScopedSelector';+import { tableColumnsByKeyScopedSelector } from '../states/selectors/tableColumnsByKeyScopedSelector';+import { visibleTableColumnsScopedSelector } from '../states/selectors/visibleTableColumnsScopedSelector';+import { tableColumnsScopedState } from '../states/tableColumnsScopedState';+import { tableFiltersScopedState } from '../states/tableFiltersScopedState';+import { tableSortsScopedState } from '../states/tableSortsScopedState';++export const getRecordTableScopeInjector = () => {+ const availableTableColumnsScopeInjector = getScopeInjector(+ availableTableColumnsScopedState,+ );++ const tableFiltersScopeInjector = getScopeInjector(tableFiltersScopedState);++ const tableSortsScopeInjector = getScopeInjector(tableSortsScopedState);++ const tableColumnsScopeInjector = getScopeInjector(tableColumnsScopedState);++ const objectMetadataConfigScopeInjector = getScopeInjector(+ objectMetadataConfigScopedState,+ );++ const tableColumnsByKeyScopeInjector = getSelectorScopeInjector(+ tableColumnsByKeyScopedSelector,+ );++ const hiddenTableColumnsScopeInjector = getSelectorScopeInjector(+ hiddenTableColumnsScopedSelector,+ );++ const visibleTableColumnsScopeInjector = getSelectorScopeInjector(+ visibleTableColumnsScopedSelector,+ );++ const onColumnsChangeScopeInjector = getScopeInjector(+ onColumnsChangeScopedState,+ );++ const onEntityCountScopeInjector = getScopeInjector(+ onEntityCountChangeScopedState,+ );++ const tableLastRowVisibleScopeInjector = getScopeInjector(+ tableLastRowVisibleScopedState,+ );++ const softFocusPositionScopeInjector = getScopeInjector(+ softFocusPositionScopedState,+ );++ const numberOfTableRowsScopeInjector = getScopeInjector(+ numberOfTableRowsScopedState,+ );++ const numberOfTableColumnsScopeInjector = getSelectorScopeInjector(+ numberOfTableColumnsScopedSelector,+ );++ const currentTableCellInEditModePositionScopeInjector = getScopeInjector(+ currentTableCellInEditModePositionScopedState,+ );++ const isTableCellInEditModeScopeInjector = getFamilyScopeInjector(+ isTableCellInEditModeScopedFamilyState,+ );++ const isSoftFocusActiveScopeInjector = getScopeInjector(+ isSoftFocusActiveScopedState,+ );++ const isSoftFocusOnTableCellScopeInjector = getFamilyScopeInjector(+ isSoftFocusOnTableCellScopedFamilyState,+ );++ const tableRowIdsScopeInjector = getScopeInjector(tableRowIdsScopedState);++ const isRowSelectedScopeInjector = getFamilyScopeInjector(+ isRowSelectedScopedFamilyState,+ );++ const allRowsSelectedStatusScopeInjector = getSelectorScopeInjector(+ allRowsSelectedStatusScopedSelector,+ );++ const selectedRowIdsScopeInjector = getSelectorScopeInjector(+ selectedRowIdsScopedSelector,+ );++ const isRecordTableInitialLoadingScopeInjector = getScopeInjector(+ isRecordTableInitialLoadingScopedState,+ );++ const resizeFieldOffsetScopeInjector = getScopeInjector(+ resizeFieldOffsetScopedState,+ );++ return {+ availableTableColumnsScopeInjector,+ tableFiltersScopeInjector,+ tableSortsScopeInjector,+ tableColumnsScopeInjector,+ objectMetadataConfigScopeInjector,+ tableColumnsByKeyScopeInjector,+ hiddenTableColumnsScopeInjector,+ visibleTableColumnsScopeInjector,+ onColumnsChangeScopeInjector,+ onEntityCountScopeInjector,+ tableLastRowVisibleScopeInjector,+ softFocusPositionScopeInjector,+ numberOfTableRowsScopeInjector,+ numberOfTableColumnsScopeInjector,+ currentTableCellInEditModePositionScopeInjector,+ isTableCellInEditModeScopeInjector,+ isSoftFocusActiveScopeInjector,+ isSoftFocusOnTableCellScopeInjector,+ tableRowIdsScopeInjector,+ isRowSelectedScopeInjector,+ allRowsSelectedStatusScopeInjector,+ selectedRowIdsScopeInjector,+ isRecordTableInitialLoadingScopeInjector,+ resizeFieldOffsetScopeInjector,+ };+};diff --git a/packages/twenty-front/src/modules/object-record/record-table/utils/getRecordTableScopedStates.ts b/packages/twenty-front/src/modules/object-record/record-table/utils/getRecordTableScopedStates.tsdeleted file mode 100644index 2cc8386c4cd..00000000000--- a/packages/twenty-front/src/modules/object-record/record-table/utils/getRecordTableScopedStates.ts+++ /dev/null@@ -1,82 +0,0 @@-import { objectMetadataConfigScopedState } from '@/object-record/record-table/states/objectMetadataConfigScopedState';-import { tableLastRowVisibleScopedState } from '@/object-record/record-table/states/tableLastRowVisibleScopedState';-import { getScopedStateDeprecated } from '@/ui/utilities/recoil-scope/utils/getScopedStateDeprecated';--import { availableTableColumnsScopedState } from '../states/availableTableColumnsScopedState';-import { onColumnsChangeScopedState } from '../states/onColumnsChangeScopedState';-import { onEntityCountChangeScopedState } from '../states/onEntityCountChange';-import { hiddenTableColumnsScopedSelector } from '../states/selectors/hiddenTableColumnsScopedSelector';-import { tableColumnsByKeyScopedSelector } from '../states/selectors/tableColumnsByKeyScopedSelector';-import { visibleTableColumnsScopedSelector } from '../states/selectors/visibleTableColumnsScopedSelector';-import { tableColumnsScopedState } from '../states/tableColumnsScopedState';-import { tableFiltersScopedState } from '../states/tableFiltersScopedState';-import { tableSortsScopedState } from '../states/tableSortsScopedState';--export const getRecordTableScopedStates = ({- recordTableScopeId,-}: {- recordTableScopeId: string;-}) => {- const availableTableColumnsState = getScopedStateDeprecated(- availableTableColumnsScopedState,- recordTableScopeId,- );-- const tableFiltersState = getScopedStateDeprecated(- tableFiltersScopedState,- recordTableScopeId,- );-- const tableSortsState = getScopedStateDeprecated(- tableSortsScopedState,- recordTableScopeId,- );-- const tableColumnsState = getScopedStateDeprecated(- tableColumnsScopedState,- recordTableScopeId,- );-- const objectMetadataConfigState = getScopedStateDeprecated(- objectMetadataConfigScopedState,- recordTableScopeId,- );-- const tableColumnsByKeySelector =- tableColumnsByKeyScopedSelector(recordTableScopeId);-- const hiddenTableColumnsSelector =- hiddenTableColumnsScopedSelector(recordTableScopeId);-- const visibleTableColumnsSelector =- visibleTableColumnsScopedSelector(recordTableScopeId);-- const onColumnsChangeState = getScopedStateDeprecated(- onColumnsChangeScopedState,- recordTableScopeId,- );-- const onEntityCountChangeState = getScopedStateDeprecated(- onEntityCountChangeScopedState,- recordTableScopeId,- );-- const tableLastRowVisibleState = getScopedStateDeprecated(- tableLastRowVisibleScopedState,- recordTableScopeId,- );-- return {- availableTableColumnsState,- tableFiltersState,- tableSortsState,- tableColumnsState,- objectMetadataConfigState,- tableColumnsByKeySelector,- hiddenTableColumnsSelector,- visibleTableColumnsSelector,- onColumnsChangeState,- onEntityCountChangeState,- tableLastRowVisibleState,- };-};diff --git a/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx b/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsxindex 8f84ad1999a..9460d4ba440 100644--- a/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx+++ b/packages/twenty-front/src/modules/pipeline/components/PipelineAddButton.tsx@@ -14,9 +14,9 @@ import { logError } from '~/utils/logError';export const PipelineAddButton = () => {const { enqueueSnackBar } = useSnackBar();- const { closeDropdown, toggleDropdown } = useDropdown({- dropdownScopeId: 'add-pipeline-progress',- });+ const { closeDropdown, toggleDropdown } = useDropdown(+ 'add-pipeline-progress',+ );const createOpportunity = useCreateOpportunity();diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsxindex a3913a43b77..dafc8d9c133 100644--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsRowDropdownMenu.tsx@@ -24,7 +24,7 @@ export const SettingsAccountsRowDropdownMenu = ({const dropdownScopeId = `settings-account-row-${account.uuid}`;const navigate = useNavigate();- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);return (<DropdownScope dropdownScopeId={dropdownScopeId}>diff --git a/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx b/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsxindex ae1a365cdf2..205853f2599 100644--- a/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/components/SettingsObjectFieldSelectFormOptionRow.tsx@@ -68,12 +68,12 @@ export const SettingsObjectFieldSelectFormOptionRow = ({return { color: `${baseScopeId}-color`, actions: `${baseScopeId}-actions` };}, []);- const { closeDropdown: closeColorDropdown } = useDropdown({- dropdownScopeId: dropdownScopeIds.color,- });- const { closeDropdown: closeActionsDropdown } = useDropdown({- dropdownScopeId: dropdownScopeIds.actions,- });+ const { closeDropdown: closeColorDropdown } = useDropdown(+ dropdownScopeIds.color,+ );+ const { closeDropdown: closeActionsDropdown } = useDropdown(+ dropdownScopeIds.actions,+ );return (<StyledRow className={className}>diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsxindex bc945c5c6a7..e93da23244e 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectAboutSection.tsx@@ -57,7 +57,7 @@ export const SettingsAboutSection = ({const { getIcon } = useIcons();const Icon = getIcon(iconKey);- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const handleEdit = () => {onEdit();diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsxindex f57360745ad..e739e882aec 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldActiveActionDropdown.tsx@@ -27,7 +27,7 @@ export const SettingsObjectFieldActiveActionDropdown = ({}: SettingsObjectFieldActiveActionDropdownProps) => {const dropdownScopeId = `${scopeKey}-settings-field-active-action-dropdown`;- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const handleEdit = () => {onEdit();diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsxindex a7a8d73eaa9..a80638e4b2b 100644--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/SettingsObjectFieldDisabledActionDropdown.tsx@@ -20,7 +20,7 @@ export const SettingsObjectFieldDisabledActionDropdown = ({}: SettingsObjectFieldDisabledActionDropdownProps) => {const dropdownScopeId = `${scopeKey}-settings-field-disabled-action-dropdown`;- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const handleActivate = () => {onActivate();diff --git a/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx b/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsxindex bdb11edcb8e..b2a5e47813c 100644--- a/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx+++ b/packages/twenty-front/src/modules/settings/data-model/objects/SettingsObjectDisabledMenuDropDown.tsx@@ -22,7 +22,7 @@ export const SettingsObjectDisabledMenuDropDown = ({}: SettingsObjectDisabledMenuDropDownProps) => {const dropdownScopeId = `${scopeKey}-settings-object-disabled-menu-dropdown`;- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const handleActivate = () => {onActivate();diff --git a/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInBackgroundMockPage.tsx b/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInBackgroundMockPage.tsxindex ec4ee3ed776..fc2f81ecb14 100644--- a/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInBackgroundMockPage.tsx+++ b/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInBackgroundMockPage.tsx@@ -27,8 +27,8 @@ export const SignInBackgroundMockPage = () => {<StyledTableContainer><SignInBackgroundMockContainer /></StyledTableContainer>- <RecordTableActionBar />- <RecordTableContextMenu />+ <RecordTableActionBar recordTableId="mock" />+ <RecordTableContextMenu recordTableId="mock" /></PageBody></PageContainer>);diff --git a/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx b/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsxindex 636ca25335a..0beec0fbf4d 100644--- a/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx@@ -95,7 +95,7 @@ export const IconPicker = ({setHotkeyScopeAndMemorizePreviousScope,} = usePreviousHotkeyScope();- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const { getIcons, getIcon } = useIcons();const icons = getIcons();diff --git a/packages/twenty-front/src/modules/ui/input/components/Select.tsx b/packages/twenty-front/src/modules/ui/input/components/Select.tsxindex 83ab05ccdbe..56fca8ed901 100644--- a/packages/twenty-front/src/modules/ui/input/components/Select.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/Select.tsx@@ -74,7 +74,7 @@ export const Select = <Value extends string | number | null>({const selectedOption =options.find(({ value: key }) => key === value) || options[0];- const { closeDropdown } = useDropdown({ dropdownScopeId });+ const { closeDropdown } = useDropdown(dropdownScopeId);const selectControl = (<StyledControlContainer disabled={disabled} fullWidth={fullWidth}>diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsxindex 73a1c8f5f77..74eec425283 100644--- a/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/internal/phone/components/CountryPickerDropdownButton.tsx@@ -75,9 +75,7 @@ export const CountryPickerDropdownButton = ({const [selectedCountry, setSelectedCountry] = useState<Country>();- const { isDropdownOpen, closeDropdown } = useDropdown({- dropdownScopeId: 'country-picker',- });+ const { isDropdownOpen, closeDropdown } = useDropdown('country-picker');const handleChange = (countryCode: string) => {onChange(countryCode);diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownScopedStates.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownScopedStates.tsnew file mode 100644index 00000000000..01e2798c810--- /dev/null+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownScopedStates.ts@@ -0,0 +1,31 @@+import { DropdownScopeInternalContext } from '@/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext';+import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';+import { useScopedState } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState';++type UseDropdownScopedStatesProps = {+ dropdownScopeId?: string;+};++export const useDropdownScopedStates = ({+ dropdownScopeId,+}: UseDropdownScopedStatesProps) => {+ const scopeId = useAvailableScopeIdOrThrow(+ DropdownScopeInternalContext,+ dropdownScopeId,+ );++ const {+ getScopedState,+ getScopedFamilyState,+ getScopedSnapshotValue,+ getScopedFamilySnapshotValue,+ } = useScopedState(scopeId);++ return {+ scopeId,+ injectStateWithDropdownScopeId: getScopedState,+ injectFamilyStateWithDropdownScopeId: getScopedFamilyState,+ injectSnapshotValueWithDropdownScopeId: getScopedSnapshotValue,+ injectFamilySnapshotValueWithDropdownScopeId: getScopedFamilySnapshotValue,+ };+};diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.tsindex 565a20261ab..e77afedf93e 100644--- a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdown.ts@@ -1,44 +1,44 @@-import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';-import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';+import { useRecoilState } from 'recoil';-import { DropdownScopeInternalContext } from '../scopes/scope-internal-context/DropdownScopeInternalContext';+import { useDropdownScopedStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownScopedStates';+import { getDropdownScopeInjectors } from '@/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors';+import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';-import { useDropdownStates } from './useDropdownStates';+export const useDropdown = (dropdownId?: string) => {+ const { injectStateWithDropdownScopeId, scopeId } = useDropdownScopedStates({+ dropdownScopeId: dropdownId,+ });-type UseDropdownProps = {- dropdownScopeId?: string;-};+ const {+ dropdownHotkeyScopeScopeInjector,+ dropdownWidthScopeInjector,+ isDropdownOpenScopeInjector,+ } = getDropdownScopeInjectors();-export const useDropdown = (props?: UseDropdownProps) => {const {setHotkeyScopeAndMemorizePreviousScope,goBackToPreviousHotkeyScope,} = usePreviousHotkeyScope();- const scopeId = useAvailableScopeIdOrThrow(- DropdownScopeInternalContext,- props?.dropdownScopeId,+ const [dropdownHotkeyScope, setDropdownHotkeyScope] = useRecoilState(+ injectStateWithDropdownScopeId(dropdownHotkeyScopeScopeInjector),);- const {- dropdownHotkeyScope,- setDropdownHotkeyScope,- isDropdownOpen,- setIsDropdownOpen,- dropdownWidth,- setDropdownWidth,- } = useDropdownStates({- scopeId,- });+ const [dropdownWidth, setDropdownWidth] = useRecoilState(+ injectStateWithDropdownScopeId(dropdownWidthScopeInjector),+ );++ const [isDropdownOpen, setIsDropdownOpen] = useRecoilState(+ injectStateWithDropdownScopeId(isDropdownOpenScopeInjector),+ );- const closeDropdownButton = () => {+ const closeDropdown = () => {goBackToPreviousHotkeyScope();setIsDropdownOpen(false);};- const openDropdownButton = () => {+ const openDropdown = () => {setIsDropdownOpen(true);-if (dropdownHotkeyScope) {setHotkeyScopeAndMemorizePreviousScope(dropdownHotkeyScope.scope,@@ -47,20 +47,20 @@ export const useDropdown = (props?: UseDropdownProps) => {}};- const toggleDropdownButton = () => {+ const toggleDropdown = () => {if (isDropdownOpen) {- closeDropdownButton();+ closeDropdown();} else {- openDropdownButton();+ openDropdown();}};return {scopeId,isDropdownOpen: isDropdownOpen,- closeDropdown: closeDropdownButton,- toggleDropdown: toggleDropdownButton,- openDropdown: openDropdownButton,+ closeDropdown,+ toggleDropdown,+ openDropdown,dropdownHotkeyScope,setDropdownHotkeyScope,dropdownWidth,diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdownStates.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdownStates.tsdeleted file mode 100644index 461ca1b3f31..00000000000--- a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/useDropdownStates.ts+++ /dev/null@@ -1,31 +0,0 @@-import { useRecoilScopedStateV2 } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2';--import { dropdownHotkeyScopeScopedState } from '../states/dropdownHotkeyScopeScopedState';-import { dropdownWidthScopedState } from '../states/dropdownWidthScopedState';-import { isDropdownOpenScopedState } from '../states/isDropdownOpenScopedState';--export const useDropdownStates = ({ scopeId }: { scopeId: string }) => {- const [isDropdownOpen, setIsDropdownOpen] = useRecoilScopedStateV2(- isDropdownOpenScopedState,- scopeId,- );-- const [dropdownHotkeyScope, setDropdownHotkeyScope] = useRecoilScopedStateV2(- dropdownHotkeyScopeScopedState,- scopeId,- );-- const [dropdownWidth, setDropdownWidth] = useRecoilScopedStateV2(- dropdownWidthScopedState,- scopeId,- );-- return {- isDropdownOpen,- setIsDropdownOpen,- dropdownHotkeyScope,- setDropdownHotkeyScope,- dropdownWidth,- setDropdownWidth,- };-};diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors.tsnew file mode 100644index 00000000000..032fe74fdfe--- /dev/null+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/utils/internal/getDropdownScopeInjectors.ts@@ -0,0 +1,22 @@+import { dropdownHotkeyScopeScopedState } from '@/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState';+import { dropdownWidthScopedState } from '@/ui/layout/dropdown/states/dropdownWidthScopedState';+import { isDropdownOpenScopedState } from '@/ui/layout/dropdown/states/isDropdownOpenScopedState';+import { getScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector';++export const getDropdownScopeInjectors = () => {+ const dropdownHotkeyScopeScopeInjector = getScopeInjector(+ dropdownHotkeyScopeScopedState,+ );++ const dropdownWidthScopeInjector = getScopeInjector(dropdownWidthScopedState);++ const isDropdownOpenScopeInjector = getScopeInjector(+ isDropdownOpenScopedState,+ );++ return {+ dropdownHotkeyScopeScopeInjector,+ dropdownWidthScopeInjector,+ isDropdownOpenScopeInjector,+ };+};diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsxindex 24468ddb4e9..924c61c56b5 100644--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx@@ -27,11 +27,10 @@ export const useSelectableListHotKeys = (}};- const { getSelectableListScopedSnapshotValue } = useSelectableListScopedState(- {+ const { injectSnapshotValueWithSelectableListScopeId } =+ useSelectableListScopedState({selectableListScopeId: scopeId,- },- );+ });const handleSelect = useRecoilCallback(({ snapshot, set }) =>@@ -42,11 +41,11 @@ export const useSelectableListHotKeys = (isSelectedItemIdFamilyScopeInjector,} = getSelectableListScopeInjectors();- const selectedItemId = getSelectableListScopedSnapshotValue(+ const selectedItemId = injectSnapshotValueWithSelectableListScopeId(snapshot,selectedItemIdScopeInjector,);- const selectableItemIds = getSelectableListScopedSnapshotValue(+ const selectableItemIds = injectSnapshotValueWithSelectableListScopeId(snapshot,selectableItemIdsScopeInjector,);@@ -120,7 +119,7 @@ export const useSelectableListHotKeys = (}}},- [getSelectableListScopedSnapshotValue, scopeId],+ [injectSnapshotValueWithSelectableListScopeId, scopeId],);useScopedHotkeys(Key.ArrowUp, () => handleSelect('up'), hotkeyScope, []);@@ -145,12 +144,12 @@ export const useSelectableListHotKeys = (selectedItemIdScopeInjector,selectableListOnEnterScopeInjector,} = getSelectableListScopeInjectors();- const selectedItemId = getSelectableListScopedSnapshotValue(+ const selectedItemId = injectSnapshotValueWithSelectableListScopeId(snapshot,selectedItemIdScopeInjector,);- const onEnter = getSelectableListScopedSnapshotValue(+ const onEnter = injectSnapshotValueWithSelectableListScopeId(snapshot,selectableListOnEnterScopeInjector,);@@ -159,7 +158,7 @@ export const useSelectableListHotKeys = (onEnter?.(selectedItemId);}},- [getSelectableListScopedSnapshotValue],+ [injectSnapshotValueWithSelectableListScopeId],),hotkeyScope,[],diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.tsindex e7a4e67e147..2388ebb1162 100644--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts@@ -23,9 +23,10 @@ export const useSelectableListScopedState = ({return {scopeId,- getSelectableListScopedState: getScopedState,- getSelectableListScopedFamilyState: getScopedFamilyState,- getSelectableListScopedSnapshotValue: getScopedSnapshotValue,- getSelectableListScopedFamilySnapshotValue: getScopedFamilySnapshotValue,+ injectStateWithSelectableListScopeId: getScopedState,+ injectFamilyStateWithSelectableListScopeId: getScopedFamilyState,+ injectSnapshotValueWithSelectableListScopeId: getScopedSnapshotValue,+ injectFamilySnapshotValueWithSelectableListScopeId:+ getScopedFamilySnapshotValue,};};diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.tsindex 782f619eb7c..ccadbba6502 100644--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts@@ -3,13 +3,13 @@ import { useResetRecoilState, useSetRecoilState } from 'recoil';import { useSelectableListScopedState } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState';import { getSelectableListScopeInjectors } from '@/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors';-export const useSelectableList = (selectableListScopeId?: string) => {+export const useSelectableList = (selectableListId?: string) => {const {- getSelectableListScopedState,- getSelectableListScopedFamilyState,+ injectStateWithSelectableListScopeId,+ injectFamilyStateWithSelectableListScopeId,scopeId,} = useSelectableListScopedState({- selectableListScopeId,+ selectableListScopeId: selectableListId,});const {@@ -20,17 +20,18 @@ export const useSelectableList = (selectableListScopeId?: string) => {} = getSelectableListScopeInjectors();const setSelectableItemIds = useSetRecoilState(- getSelectableListScopedState(selectableItemIdsScopeInjector),+ injectStateWithSelectableListScopeId(selectableItemIdsScopeInjector),);const setSelectableListOnEnter = useSetRecoilState(- getSelectableListScopedState(selectableListOnEnterScopeInjector),- );- const isSelectedItemIdFamilyState = getSelectableListScopedFamilyState(- isSelectedItemIdFamilyScopeInjector,+ injectStateWithSelectableListScopeId(selectableListOnEnterScopeInjector),);+ const isSelectedItemIdFamilyState =+ injectFamilyStateWithSelectableListScopeId(+ isSelectedItemIdFamilyScopeInjector,+ );const resetSelectedItemIdState = useResetRecoilState(- getSelectableListScopedState(selectedItemIdScopeInjector),+ injectStateWithSelectableListScopeId(selectedItemIdScopeInjector),);const resetSelectedItem = () => {diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsxindex 47344a771ea..0bc688805de 100644--- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx+++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx@@ -23,9 +23,7 @@ export const ShowPageAddButton = ({}: {entity: ActivityTargetableEntity;}) => {- const { closeDropdown, toggleDropdown } = useDropdown({- dropdownScopeId: 'add-show-page',- });+ const { closeDropdown, toggleDropdown } = useDropdown('add-show-page');const openCreateActivity = useOpenCreateActivityDrawer();const handleSelect = (type: ActivityType) => {diff --git a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsxindex 02f7cc3efd2..66b3acbce53 100644--- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx+++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx@@ -26,9 +26,7 @@ export const ShowPageMoreButton = ({recordId: string;objectNameSingular: string;}) => {- const { closeDropdown, toggleDropdown } = useDropdown({- dropdownScopeId: 'more-show-page',- });+ const { closeDropdown, toggleDropdown } = useDropdown('more-show-page');const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState);const navigate = useNavigate();diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.tsindex 6d31897b54e..592e9d53ef0 100644--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts@@ -67,10 +67,6 @@ export const useSetHotkeyScope = () =>scopesToSet.push(AppHotkeyScope.CommandMenu);}- if (newHotkeyScope.customScopes?.commandMenuOpen) {- scopesToSet.push(AppHotkeyScope.CommandMenuOpen);- }-if (newHotkeyScope?.customScopes?.goto) {scopesToSet.push(AppHotkeyScope.Goto);}diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.tsindex 3ab4e24e59b..a1a82a18462 100644--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.ts+++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.ts@@ -2,12 +2,17 @@ import { SerializableParam, Snapshot } from 'recoil';import { FamilyScopeInjector } from '@/ui/utilities/recoil-scope/utils/getFamilyScopeInjector';import { ScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector';+import { SelectorScopeInjector } from '@/ui/utilities/recoil-scope/utils/getSelectorScopeInjector';import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';export const useScopedState = (scopeId: string) => {const getScopedState = <StateType>(scopeInjector: ScopeInjector<StateType>) =>scopeInjector(scopeId);+ const getScopedSelector = <StateType>(+ scopeInjector: SelectorScopeInjector<StateType>,+ ) => scopeInjector(scopeId);+const getScopedFamilyState =<StateType, FamilyKey extends SerializableParam>(familyScopeInjector: FamilyScopeInjector<StateType, FamilyKey>,@@ -16,23 +21,30 @@ export const useScopedState = (scopeId: string) => {familyScopeInjector(scopeId, familyKey);const getScopedSnapshotValue = <StateType>(- snashot: Snapshot,+ snapshot: Snapshot,scopeInjector: ScopeInjector<StateType>,- ) => getSnapshotValue(snashot, scopeInjector(scopeId));+ ) => getSnapshotValue(snapshot, scopeInjector(scopeId));++ const getScopedSelectorSnapshotValue = <StateType>(+ snapshot: Snapshot,+ scopeInjector: SelectorScopeInjector<StateType>,+ ) => getSnapshotValue(snapshot, scopeInjector(scopeId));const getScopedFamilySnapshotValue =<StateType, FamilyKey extends SerializableParam>(- snashot: Snapshot,+ snapshot: Snapshot,familyScopeInjector: FamilyScopeInjector<StateType, FamilyKey>,) =>(familyKey: FamilyKey) =>- getSnapshotValue(snashot, familyScopeInjector(scopeId, familyKey));+ getSnapshotValue(snapshot, familyScopeInjector(scopeId, familyKey));return {scopeId,getScopedState,+ getScopedSelector,getScopedFamilyState,getScopedSnapshotValue,+ getScopedSelectorSnapshotValue,getScopedFamilySnapshotValue,};};diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.tsindex 7659fd352c6..45337270023 100644--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.ts+++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.ts@@ -8,7 +8,7 @@ export type ScopeInjector<StateType> = (export const getScopeInjector = <StateType>(scopedState: RecoilScopedState<StateType>,-) => {+): ScopeInjector<StateType> => {return (scopeId: string) =>scopedState({scopeId,diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorScopeInjector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorScopeInjector.tsnew file mode 100644index 00000000000..ffd4e49866b--- /dev/null+++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorScopeInjector.ts@@ -0,0 +1,16 @@+import { RecoilValueReadOnly } from 'recoil';++import { RecoilScopedSelector } from '@/ui/utilities/recoil-scope/types/RecoilScopedSelector';++export type SelectorScopeInjector<StateType> = (+ scopeId: string,+) => RecoilValueReadOnly<StateType>;++export const getSelectorScopeInjector = <StateType>(+ scopedSelector: RecoilScopedSelector<StateType>,+): SelectorScopeInjector<StateType> => {+ return (scopeId: string) =>+ scopedSelector({+ scopeId,+ });+};diff --git a/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx b/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsxindex 733aa1f4b20..ab2d74c90de 100644--- a/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx+++ b/packages/twenty-front/src/modules/views/components/EditableFilterDropdownButton.tsx@@ -29,9 +29,7 @@ export const EditableFilterDropdownButton = ({filterDropdownId: viewFilterDropdownId,});- const { closeDropdown } = useDropdown({- dropdownScopeId: viewFilterDropdownId,- });+ const { closeDropdown } = useDropdown(viewFilterDropdownId);const { removeViewFilter } = useViewBar();diff --git a/packages/twenty-front/src/modules/views/components/ViewBar.tsx b/packages/twenty-front/src/modules/views/components/ViewBar.tsxindex 53af0c8eaa6..aec645b4e5a 100644--- a/packages/twenty-front/src/modules/views/components/ViewBar.tsx+++ b/packages/twenty-front/src/modules/views/components/ViewBar.tsx@@ -39,9 +39,9 @@ export const ViewBar = ({onViewFiltersChange,onViewSortsChange,}: ViewBarProps) => {- const { openDropdown: openOptionsDropdownButton } = useDropdown({- dropdownScopeId: optionsDropdownScopeId,- });+ const { openDropdown: openOptionsDropdownButton } = useDropdown(+ optionsDropdownScopeId,+ );const { upsertViewSort, upsertViewFilter } = useViewBar({viewBarId: viewBarId,});diff --git a/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx b/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsxindex 7c0005cbf1b..2b3118b9a50 100644--- a/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx+++ b/packages/twenty-front/src/modules/views/components/ViewsDropdownButton.tsx@@ -84,13 +84,11 @@ export const ViewsDropdownButton = ({const {isDropdownOpen: isViewsDropdownOpen,closeDropdown: closeViewsDropdown,- } = useDropdown({- dropdownScopeId: ViewsDropdownId,- });+ } = useDropdown(ViewsDropdownId);- const { openDropdown: openOptionsDropdown } = useDropdown({- dropdownScopeId: optionsDropdownScopeId,- });+ const { openDropdown: openOptionsDropdown } = useDropdown(+ optionsDropdownScopeId,+ );const handleViewSelect = useRecoilCallback(() => async (viewId: string) => {