diff --git a/.changeset/tiny-moose-sip.md b/.changeset/tiny-moose-sip.md new file mode 100644 index 0000000000..532beadc25 --- /dev/null +++ b/.changeset/tiny-moose-sip.md @@ -0,0 +1,5 @@ +--- +"@comet/cms-admin": patch +--- + +Fix `ContentScopeIndicator` for scope with optional dimensions diff --git a/packages/admin/cms-admin/src/contentScope/ContentScopeIndicator.tsx b/packages/admin/cms-admin/src/contentScope/ContentScopeIndicator.tsx index 269ed89bc4..535c6c0d0b 100644 --- a/packages/admin/cms-admin/src/contentScope/ContentScopeIndicator.tsx +++ b/packages/admin/cms-admin/src/contentScope/ContentScopeIndicator.tsx @@ -23,7 +23,7 @@ export const ContentScopeIndicator = ({ global = false, scope: passedScope, chil const findLabelForScopePart = (scopePart: keyof ContentScopeInterface) => { const label = values.find((value) => { - return value[scopePart].value === scope[scopePart]; + return value[scopePart] && value[scopePart].value === scope[scopePart]; })?.[scopePart].label; return label ?? capitalizeString(scope[scopePart]); diff --git a/storybook/src/cms-admin/ContentScopeProvider/OptionalDimensions.tsx b/storybook/src/cms-admin/ContentScopeProvider/OptionalDimensions.tsx index df5fbfbde7..0ba4480da8 100644 --- a/storybook/src/cms-admin/ContentScopeProvider/OptionalDimensions.tsx +++ b/storybook/src/cms-admin/ContentScopeProvider/OptionalDimensions.tsx @@ -1,5 +1,5 @@ import { AppHeader, AppHeaderFillSpace, AppHeaderMenuButton, CometLogo, MainContent } from "@comet/admin"; -import { ContentScopeControls, ContentScopeProvider, ContentScopeValues, useContentScope } from "@comet/cms-admin"; +import { ContentScopeControls, ContentScopeIndicator, ContentScopeProvider, ContentScopeValues, useContentScope } from "@comet/cms-admin"; import { Typography } from "@mui/material"; import { storiesOf } from "@storybook/react"; import React from "react"; @@ -49,6 +49,7 @@ storiesOf("@comet/cms-admin/Content Scope Provider", module) + This is a development story to test optional scope dimensions in the content scope provider. Try changing the scope in the content scope select.