Skip to content

Commit b9211db

Browse files
chore: graduate primer_react_overlay_max_height_clamp_to_viewport (#7733)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent b7dfb78 commit b9211db

6 files changed

Lines changed: 55 additions & 57 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Overlay: Graduate `primer_react_overlay_max_height_clamp_to_viewport` feature flag
6+
7+
The max-height of overlays is now clamped to the viewport height by default using `min(size, 100dvh)`. This prevents overlays from extending beyond the viewport on smaller screens.

packages/react/src/ActionMenu/ActionMenu.module.css

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,43 @@
2525

2626
/* Max-height size tokens (mirror Overlay sizes) */
2727
&:where([data-max-height-xsmall]) {
28-
max-height: 192px;
29-
}
28+
max-height: min(192px, 100vh);
3029

31-
&:where([data-max-height-small]) {
32-
max-height: 256px;
30+
@supports (height: 100dvh) {
31+
max-height: min(192px, 100dvh);
32+
}
3333
}
3434

35-
&:where([data-max-height-medium]) {
36-
max-height: 320px;
37-
}
35+
&:where([data-max-height-small]) {
36+
max-height: min(256px, 100vh);
3837

39-
&:where([data-max-height-large]) {
40-
max-height: 432px;
38+
@supports (height: 100dvh) {
39+
max-height: min(256px, 100dvh);
40+
}
4141
}
4242

43-
&:where([data-max-height-xlarge]) {
44-
max-height: 600px;
45-
}
43+
&:where([data-max-height-medium]) {
44+
max-height: min(320px, 100vh);
4645

47-
/* Max-height size tokens clamped to viewport (enabled via feature flag) */
48-
&:where([data-max-height-clamp-to-viewport][data-max-height-xsmall]) {
49-
max-height: min(192px, 100dvh);
46+
@supports (height: 100dvh) {
47+
max-height: min(320px, 100dvh);
48+
}
5049
}
5150

52-
&:where([data-max-height-clamp-to-viewport][data-max-height-small]) {
53-
max-height: min(256px, 100dvh);
54-
}
51+
&:where([data-max-height-large]) {
52+
max-height: min(432px, 100vh);
5553

56-
&:where([data-max-height-clamp-to-viewport][data-max-height-medium]) {
57-
max-height: min(320px, 100dvh);
54+
@supports (height: 100dvh) {
55+
max-height: min(432px, 100dvh);
56+
}
5857
}
5958

60-
&:where([data-max-height-clamp-to-viewport][data-max-height-large]) {
61-
max-height: min(432px, 100dvh);
62-
}
59+
&:where([data-max-height-xlarge]) {
60+
max-height: min(600px, 100vh);
6361

64-
&:where([data-max-height-clamp-to-viewport][data-max-height-xlarge]) {
65-
max-height: min(600px, 100dvh);
62+
@supports (height: 100dvh) {
63+
max-height: min(600px, 100dvh);
64+
}
6665
}
6766

6867
&:where([data-max-height-fit-content]) {

packages/react/src/ActionMenu/ActionMenu.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import styles from './ActionMenu.module.css'
1818
import {useResponsiveValue, type ResponsiveValue} from '../hooks/useResponsiveValue'
1919
import {isSlot} from '../utils/is-slot'
2020
import type {FCWithSlotMarker, WithSlotMarker} from '../utils/types/Slots'
21-
import {useFeatureFlag} from '../FeatureFlags'
2221
import {DialogContext} from '../Dialog/Dialog'
2322

2423
export type MenuCloseHandler = (
@@ -330,8 +329,6 @@ const Overlay: FCWithSlotMarker<React.PropsWithChildren<MenuOverlayProps>> = ({
330329
}
331330
}, [anchorRef])
332331

333-
const featureFlagMaxHeightClampToViewport = useFeatureFlag('primer_react_overlay_max_height_clamp_to_viewport')
334-
335332
const isInsideDialog = useContext(DialogContext) !== undefined
336333

337334
return (
@@ -354,7 +351,6 @@ const Overlay: FCWithSlotMarker<React.PropsWithChildren<MenuOverlayProps>> = ({
354351
ref={containerRef}
355352
className={styles.ActionMenuContainer}
356353
data-variant={responsiveVariant}
357-
{...(featureFlagMaxHeightClampToViewport ? {'data-max-height-clamp-to-viewport': ''} : {})}
358354
{...(overlayProps.overflow ? {[`data-overflow-${overlayProps.overflow}`]: ''} : {})}
359355
{...(overlayProps.maxHeight ? {[`data-max-height-${overlayProps.maxHeight}`]: ''} : {})}
360356
>

packages/react/src/FeatureFlags/DefaultFeatureFlags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ export const DefaultFeatureFlags = FeatureFlagScope.create({
77
primer_react_select_panel_order_selected_at_top: false,
88
primer_react_select_panel_remove_active_descendant: false,
99
primer_react_spinner_synchronize_animations: false,
10-
primer_react_overlay_max_height_clamp_to_viewport: false,
1110
})

packages/react/src/Overlay/Overlay.module.css

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,44 +102,43 @@
102102
}
103103

104104
&:where([data-max-height-xsmall]) {
105-
max-height: 192px;
106-
}
105+
max-height: min(192px, 100vh);
107106

108-
&:where([data-max-height-small]) {
109-
max-height: 256px;
107+
@supports (height: 100dvh) {
108+
max-height: min(192px, 100dvh);
109+
}
110110
}
111111

112-
&:where([data-max-height-medium]) {
113-
max-height: 320px;
114-
}
112+
&:where([data-max-height-small]) {
113+
max-height: min(256px, 100vh);
115114

116-
&:where([data-max-height-large]) {
117-
max-height: 432px;
115+
@supports (height: 100dvh) {
116+
max-height: min(256px, 100dvh);
117+
}
118118
}
119119

120-
&:where([data-max-height-xlarge]) {
121-
max-height: 600px;
122-
}
120+
&:where([data-max-height-medium]) {
121+
max-height: min(320px, 100vh);
123122

124-
/* Max-height size tokens clamped to viewport (enabled via feature flag) */
125-
&:where([data-max-height-clamp-to-viewport][data-max-height-xsmall]) {
126-
max-height: min(192px, 100dvh);
123+
@supports (height: 100dvh) {
124+
max-height: min(320px, 100dvh);
125+
}
127126
}
128127

129-
&:where([data-max-height-clamp-to-viewport][data-max-height-small]) {
130-
max-height: min(256px, 100dvh);
131-
}
128+
&:where([data-max-height-large]) {
129+
max-height: min(432px, 100vh);
132130

133-
&:where([data-max-height-clamp-to-viewport][data-max-height-medium]) {
134-
max-height: min(320px, 100dvh);
131+
@supports (height: 100dvh) {
132+
max-height: min(432px, 100dvh);
133+
}
135134
}
136135

137-
&:where([data-max-height-clamp-to-viewport][data-max-height-large]) {
138-
max-height: min(432px, 100dvh);
139-
}
136+
&:where([data-max-height-xlarge]) {
137+
max-height: min(600px, 100vh);
140138

141-
&:where([data-max-height-clamp-to-viewport][data-max-height-xlarge]) {
142-
max-height: min(600px, 100dvh);
139+
@supports (height: 100dvh) {
140+
max-height: min(600px, 100dvh);
141+
}
143142
}
144143

145144
&:where([data-max-height-fit-content]) {

packages/react/src/Overlay/Overlay.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ const Overlay = React.forwardRef<HTMLDivElement, internalOverlayProps>(
192192
forwardedRef,
193193
// eslint-disable-next-line @typescript-eslint/no-explicit-any
194194
): ReactElement<any> => {
195-
const featureFlagMaxHeightClampToViewport = useFeatureFlag('primer_react_overlay_max_height_clamp_to_viewport')
196195
const overlayRef = useRef<HTMLDivElement>(null)
197196
useRefObjectAsForwardedRef(forwardedRef, overlayRef)
198197
const slideAnimationDistance = 8 // var(--base-size-8), hardcoded to do some math
@@ -245,7 +244,6 @@ const Overlay = React.forwardRef<HTMLDivElement, internalOverlayProps>(
245244
height={height}
246245
visibility={visibility}
247246
data-responsive={responsiveVariant}
248-
{...(featureFlagMaxHeightClampToViewport ? {'data-max-height-clamp-to-viewport': ''} : {})}
249247
{...props}
250248
/>
251249
)

0 commit comments

Comments
 (0)