mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-05 07:09:02 +02:00
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:
+19
-5
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user