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/select-panel-css-anchor-positioning-settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

SelectPanel: Add `cssAnchorPositioningSettings` prop to customize CSS anchor positioning behavior
12 changes: 10 additions & 2 deletions packages/react/src/SelectPanel/SelectPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ type SelectPanelVariantProps = {variant?: 'anchored'; onCancel?: () => void} | {

export type SelectPanelProps = SelectPanelBaseProps &
Omit<FilteredActionListProps, 'selectionVariant' | 'variant' | 'message'> &
Pick<AnchoredOverlayProps, 'open' | 'height' | 'width' | 'align' | 'displayInViewport'> &
Pick<
AnchoredOverlayProps,
'open' | 'height' | 'width' | 'align' | 'displayInViewport' | 'cssAnchorPositioningSettings'
> &
Comment on lines 132 to +137

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, does this need to be added to the .docs.json file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@francinelucca I'm curious what you think - I was thinking of omitting it from the docs as this is something that we don't want consumers to utilize unless they specifically need it to resolve an issue. It's in a grey area between a private and public prop 🤔

AnchoredOverlayWrapperAnchorProps &
(SelectPanelSingleSelection | SelectPanelMultiSelection) &
SelectPanelVariantProps
Expand Down Expand Up @@ -204,6 +207,7 @@ function Panel({
focusPrependedElements,
virtualized,
displayInViewport,
cssAnchorPositioningSettings,
...listProps
}: SelectPanelProps): JSX.Element {
const titleId = useId()
Expand Down Expand Up @@ -882,7 +886,11 @@ function Panel({
closeButtonProps={closeButtonProps}
displayInViewport={displayInViewport}
// Modal variant is positioned manually so native CSS anchor positioning must not be used
cssAnchorPositioningSettings={{disable: variant === 'modal'}}
// Other cssAnchorPositioningSettings (e.g. fallbackStrategy) may be passed in and are forwarded here
cssAnchorPositioningSettings={{
...cssAnchorPositioningSettings,
disable: variant === 'modal' || cssAnchorPositioningSettings?.disable,
}}
Comment on lines +889 to +893
>
<div className={classes.Wrapper} data-variant={variant} data-component="SelectPanel">
<div className={classes.Header} data-variant={currentResponsiveVariant} data-component="SelectPanel.Header">
Expand Down
Loading