Skip to content

Commit b92acec

Browse files
Adds optional captureOverscroll prop to Popover component
1 parent 432bdd5 commit b92acec

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

polaris-react/src/components/Popover/Popover.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ $vertical-motion-offset: -5px;
106106
flex: 0 0 auto;
107107
}
108108

109+
.Pane-captureOverscroll {
110+
overscroll-behavior: contain;
111+
}
112+
109113
.Section {
110114
padding: var(--p-space-4);
111115

polaris-react/src/components/Popover/Popover.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ export interface PopoverProps {
7878
autofocusTarget?: PopoverAutofocusTarget;
7979
/** Prevents closing the popover when other overlays are clicked */
8080
preventCloseOnChildOverlayClick?: boolean;
81+
/**
82+
* Prevents page scrolling when the end of the scrollable Popover overlay content is reached - applied to Pane subcomponent
83+
* @default false
84+
*/
85+
captureOverscroll?: boolean;
8186
}
8287

8388
export interface PopoverPublicAPI {

polaris-react/src/components/Popover/components/Pane/Pane.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,26 @@ export interface PaneProps {
1717
height?: string;
1818
/** Callback when the bottom of the popover is reached by mouse or keyboard */
1919
onScrolledToBottom?(): void;
20+
/**
21+
* Prevents page scrolling when the end of the scrollable Popover content is reached
22+
* @default false
23+
*/
24+
captureOverscroll?: boolean;
2025
}
2126

2227
export function Pane({
28+
captureOverscroll = false,
2329
fixed,
2430
sectioned,
2531
children,
2632
height,
2733
onScrolledToBottom,
2834
}: PaneProps) {
29-
const className = classNames(styles.Pane, fixed && styles['Pane-fixed']);
35+
const className = classNames(
36+
styles.Pane,
37+
fixed && styles['Pane-fixed'],
38+
captureOverscroll && styles['Pane-captureOverscroll'],
39+
);
3040
const content = sectioned
3141
? wrapWithComponent(children, Section, {})
3242
: children;

polaris-react/src/components/Popover/components/PopoverOverlay/PopoverOverlay.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface PopoverOverlayProps {
5757
onClose(source: PopoverCloseSource): void;
5858
autofocusTarget?: PopoverAutofocusTarget;
5959
preventCloseOnChildOverlayClick?: boolean;
60+
captureOverscroll?: boolean;
6061
}
6162

6263
interface State {
@@ -222,6 +223,7 @@ export class PopoverOverlay extends PureComponent<PopoverOverlayProps, State> {
222223
fluidContent,
223224
hideOnPrint,
224225
autofocusTarget,
226+
captureOverscroll,
225227
} = this.props;
226228

227229
const className = classNames(
@@ -248,7 +250,7 @@ export class PopoverOverlay extends PureComponent<PopoverOverlayProps, State> {
248250
style={contentStyles}
249251
ref={this.contentNode}
250252
>
251-
{renderPopoverContent(children, {sectioned})}
253+
{renderPopoverContent(children, {captureOverscroll, sectioned})}
252254
</div>
253255
);
254256

0 commit comments

Comments
 (0)