Make filters and sorts work on record page pagination (#12460)
Fixes #7929 This PR implements a system to capture and preserve the filters and sorts when navigating from an index view to a record show page. This information is stored in a context store component state. This allows users to navigate between records inside the record page while maintaining context from the index view.
This commit is contained in:
@ -7,6 +7,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { ViewOpenRecordInType } from '@/views/types/ViewOpenRecordInType';
|
||||
import { MouseEvent } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
AvatarChip,
|
||||
AvatarChipVariant,
|
||||
@ -27,6 +28,7 @@ export type RecordChipProps = {
|
||||
size?: ChipSize;
|
||||
isLabelHidden?: boolean;
|
||||
triggerEvent?: TriggerEventType;
|
||||
onClick?: (event: MouseEvent) => void;
|
||||
};
|
||||
|
||||
export const RecordChip = ({
|
||||
@ -40,6 +42,7 @@ export const RecordChip = ({
|
||||
forceDisableClick = false,
|
||||
isLabelHidden = false,
|
||||
triggerEvent = 'MOUSE_DOWN',
|
||||
onClick,
|
||||
}: RecordChipProps) => {
|
||||
const { recordChipData } = useRecordChipData({
|
||||
objectNameSingular,
|
||||
@ -53,14 +56,16 @@ export const RecordChip = ({
|
||||
const isSidePanelViewOpenRecordInType =
|
||||
recordIndexOpenRecordIn === ViewOpenRecordInType.SIDE_PANEL;
|
||||
|
||||
const handleCustomClick = isSidePanelViewOpenRecordInType
|
||||
? (_event: MouseEvent<HTMLElement>) => {
|
||||
openRecordInCommandMenu({
|
||||
recordId: record.id,
|
||||
objectNameSingular,
|
||||
});
|
||||
}
|
||||
: undefined;
|
||||
const handleCustomClick = isDefined(onClick)
|
||||
? onClick
|
||||
: isSidePanelViewOpenRecordInType
|
||||
? (_event: MouseEvent<HTMLElement>) => {
|
||||
openRecordInCommandMenu({
|
||||
recordId: record.id,
|
||||
objectNameSingular,
|
||||
});
|
||||
}
|
||||
: undefined;
|
||||
|
||||
// TODO temporary until we create a record show page for Workspaces members
|
||||
|
||||
|
||||
Reference in New Issue
Block a user