Merge pull request #27705 from overleaf/dp-view-menu-divider

Prevent extra dividers from being rendered in view toolbar menu

GitOrigin-RevId: d89761c3c650c8724154b7ea07dcf77541dc1503
This commit is contained in:
David
2025-08-11 09:50:56 +01:00
committed by Copybot
parent ac9c20e8d2
commit c414d905b1
2 changed files with 23 additions and 7 deletions
@@ -64,11 +64,10 @@ const CommandDropdown = ({
{populatedSections.map((section, index) => {
return (
<Fragment key={section.id}>
{index > 0 && <DropdownDivider />}
{section.title && <DropdownHeader>{section.title}</DropdownHeader>}
{section.children.map(child => (
<CommandDropdownChild item={child} key={child.id} />
))}
<CommandSectionContent
section={section}
includeDivider={index > 0}
/>
</Fragment>
)
})}
@@ -78,16 +77,31 @@ const CommandDropdown = ({
export const CommandSection = ({
section: sectionStructure,
includeDivider = true,
}: {
section: MenuSectionStructure<CommandId>
includeDivider?: boolean
}) => {
const { registry, shortcuts } = useCommandRegistry()
const section = populateSectionOrGroup(sectionStructure, registry, shortcuts)
return (
<CommandSectionContent section={section} includeDivider={includeDivider} />
)
}
function CommandSectionContent({
section,
includeDivider = true,
}: {
section: MenuSectionStructure<TaggedCommand>
includeDivider?: boolean
}) {
if (section.children.length === 0) {
return null
}
return (
<>
{includeDivider && <DropdownDivider />}
{section.title && <DropdownHeader>{section.title}</DropdownHeader>}
{section.children.map(child => (
<CommandDropdownChild item={child} key={child.id} />
@@ -233,8 +233,10 @@ export const ToolbarMenuBar = () => {
}
onClick={toggleMathPreview}
/>
<DropdownDivider />
<CommandSection section={pdfControlsMenuSectionStructure} />
<CommandSection
section={pdfControlsMenuSectionStructure}
includeDivider
/>
</MenuBarDropdown>
<CommandDropdown
menu={formatMenuStructure}