Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fuzzy-rabbits-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

chore: ensure max-height does not surpass viewport height in Overlay, ActionMenu
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions e2e/components/Overlay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const stories = [
title: 'Positioned Overlays',
id: 'private-components-overlay-features--positioned-overlays',
},
{
title: 'Setting Max Height',
id: 'private-components-overlay-features--setting-max-height',
},
] as const

test.describe('Overlay ', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/ActionMenu/ActionMenu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@

/* Max-height size tokens (mirror Overlay sizes) */
&:where([data-max-height-xsmall]) {
max-height: 192px;
max-height: min(192px, 100dvh);
}

&:where([data-max-height-small]) {
max-height: 256px;
max-height: min(256px, 100dvh);
}

&:where([data-max-height-medium]) {
max-height: 320px;
max-height: min(320px, 100dvh);
}

&:where([data-max-height-large]) {
max-height: 432px;
max-height: min(432px, 100dvh);
}

&:where([data-max-height-xlarge]) {
max-height: 600px;
max-height: min(600px, 100dvh);
}

&:where([data-max-height-fit-content]) {
Expand Down
14 changes: 14 additions & 0 deletions packages/react/src/Overlay/Overlay.features.stories.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,17 @@
.IssueLink:hover {
background-color: var(--bgColor-muted);
}

.ScrollableContent {
position: relative;
padding: var(--base-size-16);
display: flex;
flex-direction: column;
gap: var(--base-size-8);
}

.CloseButtonOverlay {
position: absolute;
left: var(--base-size-4);
top: var(--base-size-4);
}
63 changes: 63 additions & 0 deletions packages/react/src/Overlay/Overlay.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,66 @@ export const PositionedOverlays = ({right, role, open}: Args) => {
</div>
)
}

export const SettingMaxHeight = ({open}: Args) => {
const [isOpen, setIsOpen] = useState(false)
const buttonRef = useRef<HTMLButtonElement>(null)
const closeButtonRef = useRef<HTMLButtonElement>(null)
const closeOverlay = () => setIsOpen(false)
const containerRef = useRef<HTMLDivElement>(null)
useFocusTrap({
containerRef,
disabled: !isOpen && !open,
})

return (
<div>
<Button
ref={buttonRef}
onClick={() => {
setIsOpen(!isOpen)
}}
>
Open overlay with max height
</Button>
{isOpen || open ? (
<Overlay
initialFocusRef={closeButtonRef}
returnFocusRef={buttonRef}
ignoreClickRefs={[buttonRef]}
onEscape={closeOverlay}
onClickOutside={closeOverlay}
width="medium"
maxHeight="small"
overflow="auto"
role="dialog"
aria-modal="true"
aria-label="Overlay with max height example"
ref={containerRef}
>
<div className={classes.ScrollableContent}>
<IconButton
ref={closeButtonRef}
aria-label="Close"
onClick={closeOverlay}
icon={XIcon}
variant="invisible"
className={classes.CloseButtonOverlay}
/>
<Text as="h2">Scrollable Content</Text>
<Text as="p">
This overlay demonstrates the maxHeight property. The content below will be scrollable when it exceeds the
maximum height defined by the small size token, up to the available viewport height.
</Text>
{Array.from({length: 50}, (_, i) => (
<Text key={`item-${i}`} as="p">
Content item {i + 1}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.
</Text>
))}
</div>
</Overlay>
) : null}
</div>
)
}
10 changes: 5 additions & 5 deletions packages/react/src/Overlay/Overlay.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@
}

&:where([data-max-height-xsmall]) {
max-height: 192px;
max-height: min(192px, 100dvh);
}

&:where([data-max-height-small]) {
max-height: 256px;
max-height: min(256px, 100dvh);
}

&:where([data-max-height-medium]) {
max-height: 320px;
max-height: min(320px, 100dvh);
}

&:where([data-max-height-large]) {
max-height: 432px;
max-height: min(432px, 100dvh);
}

&:where([data-max-height-xlarge]) {
max-height: 600px;
max-height: min(600px, 100dvh);
}

&:where([data-max-height-fit-content]) {
Expand Down
Loading