Skip to content

Commit

Permalink
Fix max supported css height test
Browse files Browse the repository at this point in the history
  • Loading branch information
volkanceylan committed May 6, 2024
1 parent 2f1f64e commit 332757d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/grid/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ export function autosizeColumns(cols: Column[], availWidth: number, absoluteColM
return reRender;
}

export function getMaxSupportedCssHeight(): number {
return maxSupportedCssHeight ?? ((navigator.userAgent.toLowerCase().match(/gecko\//) ? 4000000 : 32000000));
export function getMaxSupportedCssHeight(recalc?: boolean): number {
if (!recalc && maxSupportedCssHeight != null)
return maxSupportedCssHeight;
return (maxSupportedCssHeight = ((navigator.userAgent.toLowerCase().match(/gecko\//) ? 4000000 : 32000000)));
}

export function getScrollBarDimensions(recalc?: boolean): { width: number; height: number; } {
Expand Down Expand Up @@ -335,7 +337,7 @@ export function removeUiStateHover() {
export function getVBoxDelta(el: HTMLElement): number {
if (!el)
return 0;

var style = getComputedStyle(el);
if (style.boxSizing === 'border-box')
return 0;
Expand Down
22 changes: 15 additions & 7 deletions test/grid/internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,18 @@ describe('getMaxSupportedCssHeight', () => {
const oldNavigator = window.navigator;
Object.defineProperty(window, 'navigator', {
value: {
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0'
}
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0',
},
configurable: true,
writable: true
});

expect(getMaxSupportedCssHeight()).toBe(4000000);
expect(getMaxSupportedCssHeight(true)).toBe(4000000);

Object.defineProperty(window, 'navigator', {
value: oldNavigator
value: oldNavigator,
configurable: true,
writable: true
});
});

Expand All @@ -175,13 +179,17 @@ describe('getMaxSupportedCssHeight', () => {
Object.defineProperty(window, 'navigator', {
value: {
userAgent
}
},
configurable: true,
writable: true
});

expect(userAgent + ": " + getMaxSupportedCssHeight()).toBe(userAgent + ": " + 4000000); // concat to make it easier to debug
expect(userAgent + ": " + getMaxSupportedCssHeight(true)).toBe(userAgent + ": " + 32000000); // concat to make it easier to debug

Object.defineProperty(window, 'navigator', {
value: oldNavigator
value: oldNavigator,
configurable: true,
writable: true
});
});
});
Expand Down

0 comments on commit 332757d

Please sign in to comment.