From e892c62bc77d05e7632a3d0a88634329ddcda1cc Mon Sep 17 00:00:00 2001 From: Per-Kristian Nordnes Date: Thu, 22 Dec 2022 13:59:20 +0100 Subject: [PATCH] fix(form/inputs): fix component fallback behaviour This was a regression made in f1152f740a3427cb4eaeb731402d031dd0377437 --- .../sanity/src/core/form/inputs/PortableText/text/Style.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/PortableText/text/Style.tsx b/packages/sanity/src/core/form/inputs/PortableText/text/Style.tsx index 95e31f45d43..b47e4c8ab7e 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/text/Style.tsx +++ b/packages/sanity/src/core/form/inputs/PortableText/text/Style.tsx @@ -1,12 +1,14 @@ import {Text} from '@sanity/ui' import {BlockStyleRenderProps} from '@sanity/portable-text-editor' import React, {useCallback, useMemo} from 'react' -import {TEXT_STYLES} from './textStyles' +import {Normal as FallbackComponent, TEXT_STYLES} from './textStyles' export const Style = (props: BlockStyleRenderProps) => { const {block, focused, children, selected, type, value} = props const DefaultComponent = useMemo( - () => (block.style && TEXT_STYLES[block.style] ? TEXT_STYLES[block.style] : TEXT_STYLES[0]), + () => + (block.style && TEXT_STYLES[block.style] ? TEXT_STYLES[block.style] : TEXT_STYLES[0]) || + FallbackComponent, [block.style] )