Skip to content

Commit cc784d1

Browse files
committed
Fix for URL update for entities with default selected view
1 parent f446def commit cc784d1

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

examples/example_pro/src/FirestoreApp/collections/products_collection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export const productsCollection = buildCollection<Product>({
140140
Builder: ProductsSecondaryForm
141141
}
142142
],
143+
defaultSelectedView: "sec",
143144
additionalFields: [productAdditionalField],
144145
properties: {
145146
name: {

packages/firecms_core/src/components/common/default_entity_actions.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DeleteIcon, EditIcon, FileCopyIcon } from "@firecms/ui";
22
import { EntityAction } from "../../types";
33
import { DeleteEntityDialog } from "../DeleteEntityDialog";
44
import { addRecentId } from "../EntityCollectionView/utils";
5-
import { navigateToEntity } from "../../util";
5+
import { navigateToEntity, resolveDefaultSelectedView } from "../../util";
66

77
export const editEntityAction: EntityAction = {
88
icon: <EditIcon/>,
@@ -30,15 +30,23 @@ export const editEntityAction: EntityAction = {
3030
addRecentId(collection.id, entity.id);
3131
}
3232

33-
const path = collection?.collectionGroup ? entity.path : (fullPath ?? entity.path)
33+
const path = collection?.collectionGroup ? entity.path : (fullPath ?? entity.path);
34+
const defaultSelectedView = resolveDefaultSelectedView(
35+
collection ? collection.defaultSelectedView : undefined,
36+
{
37+
status: "existing",
38+
entityId: entity.id,
39+
}
40+
);
3441
navigateToEntity({
3542
openEntityMode,
3643
collection,
3744
entityId: entity.id,
3845
path,
3946
sideEntityController: context.sideEntityController,
4047
onClose: () => unhighlightEntity?.(entity),
41-
navigation: context.navigation
48+
navigation: context.navigation,
49+
selectedTab: defaultSelectedView
4250
});
4351

4452
return Promise.resolve(undefined);

packages/formex/src/useCreateFormex.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,5 @@ export function useCreateFormex<T extends object>({
260260
controllerRef.current = controller;
261261
}, [controller]);
262262

263-
// @ts-ignore
264-
console.log("initialValuesRef.current.name", initialValuesRef.current.name);
265-
// @ts-ignore
266-
console.log("values.name", values.name);
267-
console.log("dirty", dirty);
268-
269263
return controller;
270264
}

packages/ui/src/components/Dialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type DialogProps = {
99
onOpenChange?: (open: boolean) => void;
1010
children: React.ReactNode;
1111
className?: string;
12+
containerClassName?: string;
1213
fullWidth?: boolean;
1314
fullHeight?: boolean;
1415
fullScreen?: boolean;
@@ -41,6 +42,7 @@ export const Dialog = ({
4142
onOpenChange,
4243
children,
4344
className,
45+
containerClassName,
4446
fullWidth = true,
4547
fullHeight,
4648
fullScreen,
@@ -73,7 +75,7 @@ export const Dialog = ({
7375
onOpenChange={onOpenChange}>
7476
<DialogPrimitive.Portal>
7577

76-
<div className={"fixed inset-0 z-30"}>
78+
<div className={cls("fixed inset-0 z-30", containerClassName)}>
7779

7880
<DialogPrimitive.Overlay
7981
className={cls("fixed inset-0 transition-opacity z-20 ease-in-out duration-200 bg-black bg-opacity-50 dark:bg-opacity-60 backdrop-blur-sm ",

0 commit comments

Comments
 (0)