Skip to content

Commit

Permalink
fix(components/ag-grid): allow overriding grid min-height (#3077)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhwhite authored Jan 31, 2025
1 parent c7e0312 commit b9b6c7d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[ngClass]="wrapperClasses$ | async"
[id]="gridId"
[skyViewkeeper]="viewkeeperClasses"
[style]="minHeightStyle()"
(keydown)="onGridKeydown($event)"
(keyup.escape)="onKeyUpEscape($event)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ describe('SkyAgGridWrapperComponent', () => {
await expectAsync(gridWrapperNativeElement).toBeAccessible();
});

it('should set the min height', () => {
gridWrapperFixture.componentRef.setInput('minHeight', 150);
gridWrapperFixture.detectChanges();
expect(
gridWrapperNativeElement
.querySelector('div.sky-ag-grid')
?.getAttribute('style'),
).toEqual('--sky-ag-grid-min-height: 150px;');
});

it('should add .ag-header to the viewkeeper classes when the domLayout is set to autoHeight', () => {
agGrid.gridOptions = { domLayout: 'autoHeight' };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
OnDestroy,
OnInit,
booleanAttribute,
computed,
inject,
input,
numberAttribute,
} from '@angular/core';
import { SkyMutationObserverService } from '@skyux/core';
import {
Expand Down Expand Up @@ -74,6 +77,13 @@ export class SkyAgGridWrapperComponent
this.#isCompact.next(value);
}

/**
* The minimum height of the grid in pixels. The default value is `50`.
*/
public readonly minHeight = input<number, unknown>(50, {
transform: numberAttribute,
});

public afterAnchorId: string;
public beforeAnchorId: string;
public gridId: string;
Expand Down Expand Up @@ -113,6 +123,10 @@ export class SkyAgGridWrapperComponent
return false;
}

protected readonly minHeightStyle = computed(() => {
return `--sky-ag-grid-min-height: ${this.minHeight()}px;`;
});

#_viewkeeperClasses: string[] = [];
readonly #ngUnsubscribe = new Subject<void>();
readonly #themeSvc = inject(SkyThemeService, {
Expand Down
4 changes: 4 additions & 0 deletions libs/components/ag-grid/src/lib/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ $modernDarkThemeCompact: map.merge($modernDarkThemeBase, $modernThemeCompact);
cursor: initial;
}

.ag-layout-auto-height .ag-body .ag-center-cols-viewport {
min-height: var(--sky-ag-grid-min-height, 50px);
}

.ag-scrollbar-invisible.sky-viewkeeper-fixed {
box-shadow: none;
}
Expand Down

0 comments on commit b9b6c7d

Please sign in to comment.