Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
Merged
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/four-pens-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added support for setting `maxHeight` and `minHeight` on `Popover.Pane` and `Combobox`
13 changes: 12 additions & 1 deletion polaris-react/src/components/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export interface ComboboxProps {
/** Height to set on the Popover Pane. */
height?: string;
/** Callback fired when the bottom of the listbox is reached. Use to lazy load when listbox option data is paginated. */
maxHeight?: string;
/** Min Height to set on the Popover Pane. */
minHeight?: string;
/** Callback fired when the bottom of the lisbox is reached. Use to lazy load when listbox option data is paginated. */
onScrolledToBottom?(): void;
/** Callback fired when the popover closes */
onClose?(): void;
Expand All @@ -44,6 +48,8 @@ export function Combobox({
preferredPosition = 'below',
willLoadMoreOptions,
height,
maxHeight,
minHeight,
onScrolledToBottom,
onClose,
}: ComboboxProps) {
Expand Down Expand Up @@ -167,7 +173,12 @@ export function Combobox({
onClose={handleClose}
>
{Children.count(children) > 0 ? (
<Popover.Pane onScrolledToBottom={onScrolledToBottom} height={height}>
<Popover.Pane
onScrolledToBottom={onScrolledToBottom}
height={height}
maxHeight={maxHeight}
minHeight={minHeight}
>
<ComboboxListboxContext.Provider value={listboxContextValue}>
<ComboboxListboxOptionContext.Provider
value={listboxOptionContextValue}
Expand Down
13 changes: 9 additions & 4 deletions polaris-react/src/components/Popover/components/Pane/Pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ export interface PaneProps {
sectioned?: boolean;
/** The pane content */
children?: React.ReactNode;
/** Sets a fixed height and max-height on the Scrollable */
/** Sets a fixed height on the Scrollable */
height?: string;
/** Sets maxHeight on the Scrollable */
maxHeight?: string;
/** Sets minHeight on the Scrollable */
minHeight?: string;
/** Callback when the bottom of the popover is reached by mouse or keyboard */
onScrolledToBottom?(): void;
/**
Expand All @@ -35,6 +39,8 @@ export function Pane({
sectioned,
children,
height,
maxHeight,
minHeight,
subdued,
onScrolledToBottom,
}: PaneProps) {
Expand All @@ -47,9 +53,8 @@ export function Pane({
const content = sectioned
? wrapWithComponent(children, Section, {})
: children;
const style = height
? {height, maxHeight: height, minHeight: height}
: undefined;

const style = {height, maxHeight, minHeight};

return fixed ? (
<div style={style} className={className}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ describe('<Pane />', () => {
</TextContainer>
);

const popoverPane = mountWithApp(
<Pane height={height} maxHeight={height} minHeight={height}>
<Children />
</Pane>,
);

expect(popoverPane).toContainReactComponent(Scrollable, {
style,
});
});

it('sets a height on Scrollable', () => {
const height = '100px';
const style = {height};
const Children = () => (
<TextContainer>
<p>Text</p>
</TextContainer>
);

const popoverPane = mountWithApp(
<Pane height={height}>
<Children />
Expand All @@ -191,6 +211,46 @@ describe('<Pane />', () => {
style,
});
});

it('sets a maxHeight on Scrollable', () => {
const height = '100px';
const style = {maxHeight: height};
const Children = () => (
<TextContainer>
<p>Text</p>
</TextContainer>
);

const popoverPane = mountWithApp(
<Pane maxHeight={height}>
<Children />
</Pane>,
);

expect(popoverPane).toContainReactComponent(Scrollable, {
style,
});
});

it('sets a minHeight on Scrollable', () => {
const height = '100px';
const style = {minHeight: height};
const Children = () => (
<TextContainer>
<p>Text</p>
</TextContainer>
);

const popoverPane = mountWithApp(
<Pane minHeight={height}>
<Children />
</Pane>,
);

expect(popoverPane).toContainReactComponent(Scrollable, {
style,
});
});
});

describe('captureOverscroll', () => {
Expand Down