Skip to content

Commit

Permalink
fix(material/bottom-sheet): add height minHeight maxHeight to c…
Browse files Browse the repository at this point in the history
…onfig (#29794)

these properties were missing from the config but still worked as they were passed to dialog under the hood to avoid type errors

fixes #28832

(cherry picked from commit d4adbaa)
  • Loading branch information
naaajii authored and crisbeto committed Nov 11, 2024
1 parent b57f7b6 commit de6c206
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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

0 comments on commit de6c206

Please sign in to comment.