Skip to content

Commit 73a45df

Browse files
TylerJDevCopilot
andauthored
Allow CSS anchor positioning in SelectPanel settings (#8026)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent cb79351 commit 73a45df

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
SelectPanel: Add `cssAnchorPositioningSettings` prop to customize CSS anchor positioning behavior

packages/react/src/SelectPanel/SelectPanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ type SelectPanelVariantProps = {variant?: 'anchored'; onCancel?: () => void} | {
131131

132132
export type SelectPanelProps = SelectPanelBaseProps &
133133
Omit<FilteredActionListProps, 'selectionVariant' | 'variant' | 'message'> &
134-
Pick<AnchoredOverlayProps, 'open' | 'height' | 'width' | 'align' | 'displayInViewport'> &
134+
Pick<
135+
AnchoredOverlayProps,
136+
'open' | 'height' | 'width' | 'align' | 'displayInViewport' | 'cssAnchorPositioningSettings'
137+
> &
135138
AnchoredOverlayWrapperAnchorProps &
136139
(SelectPanelSingleSelection | SelectPanelMultiSelection) &
137140
SelectPanelVariantProps
@@ -204,6 +207,7 @@ function Panel({
204207
focusPrependedElements,
205208
virtualized,
206209
displayInViewport,
210+
cssAnchorPositioningSettings,
207211
...listProps
208212
}: SelectPanelProps): JSX.Element {
209213
const titleId = useId()
@@ -902,7 +906,11 @@ function Panel({
902906
closeButtonProps={closeButtonProps}
903907
displayInViewport={displayInViewport}
904908
// Modal variant is positioned manually so native CSS anchor positioning must not be used
905-
cssAnchorPositioningSettings={{disable: variant === 'modal'}}
909+
// Other cssAnchorPositioningSettings (e.g. fallbackStrategy) may be passed in and are forwarded here
910+
cssAnchorPositioningSettings={{
911+
...cssAnchorPositioningSettings,
912+
disable: variant === 'modal' || cssAnchorPositioningSettings?.disable,
913+
}}
906914
>
907915
<div className={classes.Wrapper} data-variant={variant} data-component="SelectPanel">
908916
<div className={classes.Header} data-variant={currentResponsiveVariant} data-component="SelectPanel.Header">

0 commit comments

Comments
 (0)