From 4918a9e5fa7fdc4857ffbbfa7999ef7ab70065c6 Mon Sep 17 00:00:00 2001 From: Phat Tran <45039354+phattran2905@users.noreply.github.com> Date: Mon, 16 Sep 2024 00:17:52 -0700 Subject: [PATCH] fix(core): correctly reset PTE list counts after non-numbered lists and in sublists (#7506) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(core): reset list count for sub-list items * fixup! fix(core): reset list count for sub-list items --------- Co-authored-by: Christian Hamburger Grøngaard --- .../form/inputs/PortableText/Editor.styles.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx b/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx index ccf1d036b2c..458399b72ed 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx +++ b/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx @@ -95,7 +95,6 @@ export const EditableWrapper = styled(Card)<{$isFullscreen: boolean; $readOnly?: & > .pt-list-item-bullet + .pt-list-item-number, & > .pt-list-item-number + .pt-list-item-bullet { margin-top: ${({theme}) => theme.sanity.space[3]}px; - counter-reset: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')}; } & > :not(.pt-list-item) + .pt-list-item { @@ -107,13 +106,12 @@ export const EditableWrapper = styled(Card)<{$isFullscreen: boolean; $readOnly?: counter-set: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')}; } - ${TEXT_LEVELS.slice(1).map((l) => { - return css` - & > .pt-list-item-level-${l} + .pt-list-item-level-${l - 1} { - counter-reset: ${createListName(l)}; - } - ` - })} + /* Reset the list count all the sub-list items */ + & > .pt-list-item-number.pt-list-item-level-${TEXT_LEVELS[0]} { + counter-set: ${TEXT_LEVELS.slice(1) + .map((l) => createListName(l)) + .join(' ')}; + } & > .pt-list-item + :not(.pt-list-item) { margin-top: ${({theme}) => theme.sanity.space[3]}px;