diff --git a/.changeset/green-foxes-appear.md b/.changeset/green-foxes-appear.md new file mode 100644 --- /dev/null +++ b/.changeset/green-foxes-appear.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Removes the `popover` attribute from the sidebar pane on desktop viewports. This ensures the desktop sidebar doesn't stay in a "hidden" popover visibility state. diff --git a/packages/starlight/src/components/PageFrame.astro b/packages/starlight/src/components/PageFrame.astro --- a/packages/starlight/src/components/PageFrame.astro +++ b/packages/starlight/src/components/PageFrame.astro @@ -17,8 +17,14 @@ constructor() { super(); - // Close the menu when the viewport is resized between mobile and desktop sizes. - matchMedia('(min-width: 50em)').addEventListener('change', () => this.hidePopover()); + const desktopMediaQuery = matchMedia('(min-width: 50em)'); + + // Remove the popover attribute on desktop viewports. It's only needed for the mobile menu. + const resetPopoverAttribute = () => { + this.popover = desktopMediaQuery.matches ? null : 'auto'; + } + resetPopoverAttribute(); + desktopMediaQuery.addEventListener('change', () => resetPopoverAttribute()); // Update the menu state when the sidebar popover is toggled. this.addEventListener('toggle', ({ newState }) => this.trapFocus(newState === 'open'));