From 762f6abeb56e71f5d62e378055c912b9b6d7d8b9 Mon Sep 17 00:00:00 2001 From: RitaDias Date: Tue, 20 Aug 2024 10:59:13 +0200 Subject: [PATCH] fix(sanity): update the title to be ellipsed when the text is too long (#7380) * fix(sanity): update the title to remain ellipsed when it's too long * refactor(sanity): add title to the title (hovering) * refactor(sanity): remove inline style for flex + hoist inline style --- .../header/DocumentHeaderTitle.tsx | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx index 6e05c51324e..d976580004b 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.tsx @@ -2,11 +2,17 @@ import {DocumentIcon} from '@sanity/icons' import {Flex, Text} from '@sanity/ui' import {createElement, memo, type ReactElement} from 'react' import {unstable_useValuePreview as useValuePreview, useTranslation} from 'sanity' +import {styled} from 'styled-components' import {structureLocaleNamespace} from '../../../../i18n' import {useDocumentPane} from '../../useDocumentPane' import {DocumentPerspectiveMenu} from './perspective/DocumentPerspectiveMenu' +const TitleContainer = styled(Text)` + max-width: 100%; + min-width: 0; +` + export const DocumentHeaderTitle = memo(function DocumentHeaderTitle(): ReactElement { const {connectionState, schemaType, title, value: documentValue} = useDocumentPane() const subscribed = Boolean(documentValue) && connectionState !== 'connecting' @@ -41,23 +47,21 @@ export const DocumentHeaderTitle = memo(function DocumentHeaderTitle(): ReactEle } return ( - - - {createElement(schemaType?.options?.icon || DocumentIcon)} - - {value?.title || ( - - {t('panes.document-header-title.untitled.text')} - - )} - - - + + {createElement(schemaType?.options?.icon || DocumentIcon)} + + {value?.title || ( + + {t('panes.document-header-title.untitled.text')} + + )} +