Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/bottom-sheet): add height minHeight maxHeight to config #29794

Merged
merged 1 commit into from
Nov 11, 2024
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
9 changes: 9 additions & 0 deletions src/material/bottom-sheet/bottom-sheet-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ export class MatBottomSheetConfig<D = any> {

/** Scroll strategy to be used for the bottom sheet. */
scrollStrategy?: ScrollStrategy;

/** Height for the bottom sheet. */
height?: string = '';

/** Minimum height for the bottom sheet. If a number is provided, assumes pixel units. */
minHeight?: number | string;

/** Maximum height for the bottom sheet. If a number is provided, assumes pixel units. */
maxHeight?: number | string;
}
18 changes: 18 additions & 0 deletions src/material/bottom-sheet/bottom-sheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,24 @@ describe('MatBottomSheet', () => {
expect(scrollStrategy.enable).toHaveBeenCalled();
});

it('should contain the height style properties on overlay pane', () => {
bottomSheet.open(PizzaMsg, {
panelClass: 'height--pane',
height: '300px',
maxHeight: 400, // this is converted into pixels
minHeight: 200, // this is converted into pixels
});

viewContainerFixture.detectChanges();

const paneElement = overlayContainerElement.querySelector('.height--pane') as HTMLElement;

expect(paneElement).toBeTruthy();
expect(paneElement.style.height).toBe('300px');
expect(paneElement.style.maxHeight).toBe('400px');
expect(paneElement.style.minHeight).toBe('200px');
});

describe('passing in data', () => {
it('should be able to pass in data', () => {
const config = {
Expand Down
3 changes: 3 additions & 0 deletions tools/public_api_guard/material/bottom-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class MatBottomSheetConfig<D = any> {
direction?: Direction;
disableClose?: boolean;
hasBackdrop?: boolean;
height?: string;
maxHeight?: number | string;
minHeight?: number | string;
panelClass?: string | string[];
restoreFocus?: boolean;
scrollStrategy?: ScrollStrategy;
Expand Down
Loading