Skip to content

Commit de005ab

Browse files
committed
Polish tablet expanded table zoom
1 parent c6168d4 commit de005ab

2 files changed

Lines changed: 65 additions & 5 deletions

File tree

tests/browser/browserSmoke.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,42 @@ async function exerciseTabletLandscapeMobileParity(page, queryApiStub) {
18801880
await expectMobileScrollLockReleased(page, 'Tablet landscape export dialog');
18811881
await cleanupMobilePageScroll(page);
18821882

1883+
await page.locator('[data-mobile-table-action-target="table-expand-btn"]').click();
1884+
await page.waitForFunction(() => document.body.classList.contains('table-expanded-open'), null, { timeout: 5000 });
1885+
await expectElementWithinViewport(page, '#table-shell.table-shell-expanded', 'Tablet landscape expanded table');
1886+
const tabletExpandedTableMetrics = await page.locator('#table-shell.table-shell-expanded').evaluate(shell => {
1887+
const topBar = shell.querySelector('#table-top-bar');
1888+
const container = shell.querySelector('#table-container');
1889+
const table = shell.querySelector('#example-table');
1890+
const topBarRect = topBar?.getBoundingClientRect();
1891+
const containerRect = container?.getBoundingClientRect();
1892+
const tableRect = table?.getBoundingClientRect();
1893+
const shellRect = shell.getBoundingClientRect();
1894+
return {
1895+
containerHeight: containerRect?.height || 0,
1896+
containerTop: containerRect?.top || 0,
1897+
containerWidth: containerRect?.width || 0,
1898+
shellBottomGap: Math.abs(window.innerHeight - (shellRect?.bottom || 0)),
1899+
shellTop: shellRect?.top || 0,
1900+
tableWidth: tableRect?.width || 0,
1901+
tableZoom: shell.style.getPropertyValue('--table-zoom') || '',
1902+
topBarHeight: topBarRect?.height || 0,
1903+
viewportHeight: window.innerHeight
1904+
};
1905+
});
1906+
if (
1907+
tabletExpandedTableMetrics.tableZoom !== '1.00'
1908+
|| tabletExpandedTableMetrics.topBarHeight > 70
1909+
|| tabletExpandedTableMetrics.containerHeight < tabletExpandedTableMetrics.viewportHeight - 110
1910+
|| tabletExpandedTableMetrics.tableWidth > tabletExpandedTableMetrics.containerWidth + 4
1911+
|| tabletExpandedTableMetrics.shellTop > 10
1912+
|| tabletExpandedTableMetrics.shellBottomGap > 10
1913+
) {
1914+
throw new Error(`Tablet landscape expanded table should keep mobile chrome while using full tablet table zoom: ${JSON.stringify(tabletExpandedTableMetrics)}`);
1915+
}
1916+
await page.locator('#table-expand-btn').click();
1917+
await page.waitForFunction(() => !document.body.classList.contains('table-expanded-open'), null, { timeout: 5000 });
1918+
18831919
await page.locator('#mobile-builder-toggle').click();
18841920
await page.waitForFunction(() => document.querySelector('#mobile-builder-drawer')?.classList.contains('is-open'), null, { timeout: 5000 });
18851921
const builderMetrics = await page.evaluate(() => {

ui/queryUI.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ function isMobileTableViewport() {
4343
&& window.matchMedia('(max-width: 1180px)').matches;
4444
}
4545

46+
function isTabletWidthMobileViewport() {
47+
return typeof window !== 'undefined'
48+
&& typeof window.matchMedia === 'function'
49+
&& window.matchMedia('(min-width: 700px) and (max-width: 1180px)').matches;
50+
}
51+
52+
function getResponsiveExpandedTableZoomLimit() {
53+
if (!isMobileTableViewport()) {
54+
return null;
55+
}
56+
57+
return isTabletWidthMobileViewport() ? 1 : 0.9;
58+
}
59+
4660
function getConfiguredFilterCount() {
4761
return Object.values(getActiveFilters()).reduce((total, data) => {
4862
return total + (data && Array.isArray(data.filters) ? data.filters.length : 0);
@@ -407,10 +421,18 @@ function updateTableChromeState() {
407421

408422
const expanded = tableShell.classList.contains('table-shell-expanded');
409423
const isMobileViewport = isMobileTableViewport();
410-
if (expanded && isMobileViewport && getTableZoom() > 0.9) {
411-
tableShell.dataset.zoom = '0.90';
424+
const responsiveExpandedZoom = expanded ? getResponsiveExpandedTableZoomLimit() : null;
425+
const currentZoom = getTableZoom();
426+
if (
427+
responsiveExpandedZoom !== null
428+
&& (
429+
currentZoom > responsiveExpandedZoom
430+
|| tableShell.dataset.responsiveMobileZoom === 'true'
431+
)
432+
) {
433+
tableShell.dataset.zoom = responsiveExpandedZoom.toFixed(2);
412434
tableShell.dataset.responsiveMobileZoom = 'true';
413-
} else if (expanded && !isMobileViewport && tableShell.dataset.responsiveMobileZoom === 'true') {
435+
} else if (expanded && responsiveExpandedZoom === null && tableShell.dataset.responsiveMobileZoom === 'true') {
414436
tableShell.dataset.zoom = '1.00';
415437
delete tableShell.dataset.responsiveMobileZoom;
416438
} else if (!expanded) {
@@ -478,8 +500,10 @@ function toggleTableExpanded(forceExpanded) {
478500
tableShell.classList.toggle('table-shell-expanded', expanded);
479501
document.body.classList.toggle('table-expanded-open', expanded);
480502

481-
if (expanded && isMobileTableViewport() && getTableZoom() > 0.9) {
482-
tableShell.dataset.zoom = '0.90';
503+
const responsiveExpandedZoom = expanded ? getResponsiveExpandedTableZoomLimit() : null;
504+
if (responsiveExpandedZoom !== null && getTableZoom() > responsiveExpandedZoom) {
505+
tableShell.dataset.zoom = responsiveExpandedZoom.toFixed(2);
506+
tableShell.dataset.responsiveMobileZoom = 'true';
483507
}
484508

485509
if (!expanded) {

0 commit comments

Comments
 (0)