Fix unable to reopen record after going back in side panel (#12523)
Before: https://github.com/user-attachments/assets/25ab8857-ed83-41be-9952-2108443d3e3c After: https://github.com/user-attachments/assets/c161c194-1f41-4197-8d5c-f824c6cb5e73
This commit is contained in:
@ -2,6 +2,7 @@ import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
|
||||
import { viewableRecordIdComponentState } from '@/command-menu/pages/record-page/states/viewableRecordIdComponentState';
|
||||
import { viewableRecordNameSingularComponentState } from '@/command-menu/pages/record-page/states/viewableRecordNameSingularComponentState';
|
||||
import { commandMenuNavigationMorphItemByPageState } from '@/command-menu/states/commandMenuNavigationMorphItemsState';
|
||||
import { commandMenuNavigationStackState } from '@/command-menu/states/commandMenuNavigationStackState';
|
||||
import { CommandMenuPages } from '@/command-menu/types/CommandMenuPages';
|
||||
import { MAIN_CONTEXT_STORE_INSTANCE_ID } from '@/context-store/constants/MainContextStoreInstanceId';
|
||||
import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataItemIdComponentState';
|
||||
@ -14,11 +15,12 @@ import { objectMetadataItemFamilySelector } from '@/object-metadata/states/objec
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { getIconColorForObjectType } from '@/object-metadata/utils/getIconColorForObjectType';
|
||||
import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';
|
||||
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
|
||||
import { useRunWorkflowRunOpeningInCommandMenuSideEffects } from '@/workflow/hooks/useRunWorkflowRunOpeningInCommandMenuSideEffects';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
@ -41,11 +43,24 @@ export const useOpenRecordInCommandMenu = () => {
|
||||
objectNameSingular: string;
|
||||
isNewRecord?: boolean;
|
||||
}) => {
|
||||
const lastRecordId = snapshot
|
||||
.getLoadable(viewableRecordIdState)
|
||||
.getValue();
|
||||
if (lastRecordId === recordId) {
|
||||
return;
|
||||
const navigationStack = getSnapshotValue(
|
||||
snapshot,
|
||||
commandMenuNavigationStackState,
|
||||
);
|
||||
|
||||
const currentNavigationStackItem = navigationStack.at(-1);
|
||||
|
||||
if (isDefined(currentNavigationStackItem)) {
|
||||
const currentRecordId = getSnapshotValue(
|
||||
snapshot,
|
||||
viewableRecordIdComponentState.atomFamily({
|
||||
instanceId: currentNavigationStackItem.pageId,
|
||||
}),
|
||||
);
|
||||
|
||||
if (currentRecordId === recordId) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const pageComponentInstanceId = v4();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { createState } from 'twenty-ui/utilities';
|
||||
|
||||
export const viewableRecordIdState = createState<string | null>({
|
||||
key: 'activities/viewable-record-id',
|
||||
defaultValue: null,
|
||||
|
||||
Reference in New Issue
Block a user