Skip to content

Commit 54ff2a3

Browse files
Rename fullScreenOnNarrow prop to fullScreenOptOut with inverted logic
Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
1 parent c071e39 commit 54ff2a3

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

packages/react/src/SelectPanel/SelectPanel.docs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@
183183
"type": "boolean",
184184
"description": "Whether to display the selected items at the top of the list",
185185
"default": "true"
186+
},
187+
{
188+
"name": "fullScreenOptOut",
189+
"type": "boolean",
190+
"description": "Whether to opt out of fullscreen behavior on narrow viewports. When `true`, the panel will maintain its anchored position regardless of viewport size. When `false`, the panel will go fullscreen on narrow viewports (if feature flag is enabled).",
191+
"defaultValue": "undefined (uses feature flag default)"
186192
}
187193
],
188194
"subcomponents": []

packages/react/src/SelectPanel/SelectPanel.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ for (const useModernActionList of [false, true]) {
10671067
})
10681068
})
10691069

1070-
describe('fullScreenOnNarrow prop', () => {
1070+
describe('fullScreenOptOut prop', () => {
10711071
const renderSelectPanelWithFlags = (flags: Record<string, boolean>, props: Record<string, unknown> = {}) => {
10721072
return render(
10731073
<FeatureFlags flags={flags}>
@@ -1078,45 +1078,45 @@ for (const useModernActionList of [false, true]) {
10781078
)
10791079
}
10801080

1081-
it('should respect fullScreenOnNarrow=false even when feature flag is enabled', async () => {
1081+
it('should opt out of fullscreen when fullScreenOptOut=true even when feature flag is enabled', async () => {
10821082
const user = userEvent.setup()
10831083

10841084
renderSelectPanelWithFlags(
10851085
{
10861086
primer_react_select_panel_with_modern_action_list: useModernActionList,
10871087
primer_react_select_panel_fullscreen_on_narrow: true,
10881088
},
1089-
{fullScreenOnNarrow: false},
1089+
{fullScreenOptOut: true},
10901090
)
10911091

10921092
await user.click(screen.getByText('Select items'))
10931093

1094-
// When fullScreenOnNarrow=false, the overlay should not use responsive fullscreen variant
1094+
// When fullScreenOptOut=true, the overlay should not use responsive fullscreen variant
10951095
const dialog = screen.getByRole('dialog')
10961096
expect(dialog).toBeInTheDocument()
10971097
// The key test is that the AnchoredOverlay's variant prop should be undefined
1098-
// when fullScreenOnNarrow is false, regardless of feature flag
1098+
// when fullScreenOptOut is true, regardless of feature flag
10991099
})
11001100

1101-
it('should use fullscreen behavior when fullScreenOnNarrow=true and feature flag is enabled', async () => {
1101+
it('should use fullscreen behavior when fullScreenOptOut=false and feature flag is enabled', async () => {
11021102
const user = userEvent.setup()
11031103

11041104
renderSelectPanelWithFlags(
11051105
{
11061106
primer_react_select_panel_with_modern_action_list: useModernActionList,
11071107
primer_react_select_panel_fullscreen_on_narrow: true,
11081108
},
1109-
{fullScreenOnNarrow: true},
1109+
{fullScreenOptOut: false},
11101110
)
11111111

11121112
await user.click(screen.getByText('Select items'))
11131113

1114-
// When both feature flag and prop are true, should enable fullscreen behavior
1114+
// When feature flag is true and fullScreenOptOut is false, should enable fullscreen behavior
11151115
const dialog = screen.getByRole('dialog')
11161116
expect(dialog).toBeInTheDocument()
11171117
})
11181118

1119-
it('should default to feature flag value when fullScreenOnNarrow is undefined', async () => {
1119+
it('should default to feature flag value when fullScreenOptOut is undefined', async () => {
11201120
const user = userEvent.setup()
11211121

11221122
// Test with feature flag disabled

packages/react/src/SelectPanel/SelectPanel.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ interface SelectPanelBaseProps {
102102
footer?: string | React.ReactElement
103103
showSelectedOptionsFirst?: boolean
104104
/**
105-
* Whether the SelectPanel should go fullscreen on narrow viewports.
106-
* When `false`, the panel will maintain its anchored position regardless of viewport size.
107-
* @default true when the primer_react_select_panel_fullscreen_on_narrow feature flag is enabled
105+
* Whether to opt out of fullscreen behavior on narrow viewports.
106+
* When `true`, the panel will maintain its anchored position regardless of viewport size.
107+
* When `false`, the panel will go fullscreen on narrow viewports (if feature flag is enabled).
108+
* @default undefined (uses feature flag default)
108109
*/
109-
fullScreenOnNarrow?: boolean
110+
fullScreenOptOut?: boolean
110111
}
111112

112113
// onCancel is optional with variant=anchored, but required with variant=modal
@@ -178,7 +179,7 @@ function Panel({
178179
variant = 'anchored',
179180
secondaryAction,
180181
showSelectedOptionsFirst = true,
181-
fullScreenOnNarrow,
182+
fullScreenOptOut,
182183
...listProps
183184
}: SelectPanelProps): JSX.Element {
184185
const titleId = useId()
@@ -200,7 +201,7 @@ function Panel({
200201

201202
const usingModernActionList = useFeatureFlag('primer_react_select_panel_with_modern_action_list')
202203
const featureFlagFullScreenOnNarrow = useFeatureFlag('primer_react_select_panel_fullscreen_on_narrow')
203-
const usingFullScreenOnNarrow = fullScreenOnNarrow ?? featureFlagFullScreenOnNarrow
204+
const usingFullScreenOnNarrow = fullScreenOptOut !== undefined ? !fullScreenOptOut : featureFlagFullScreenOnNarrow
204205
const shouldOrderSelectedFirst =
205206
useFeatureFlag('primer_react_select_panel_order_selected_at_top') && showSelectedOptionsFirst
206207

0 commit comments

Comments
 (0)