Skip to content
Closed
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
1 change: 1 addition & 0 deletions projects/packages/premium-analytics/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ vendor/
node_modules/
build/
build-module/
build-style/
composer.lock
.phpunit.cache/
4 changes: 4 additions & 0 deletions projects/packages/premium-analytics/changelog/wooa7s-1991
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix scrolling on the dashboard when the wp-admin menu is taller than the window.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@use "@wordpress/base-styles/breakpoints";
@use "@wordpress/base-styles/variables" as vars;

/*
* Let the page be the only scroll container on desktop. A scroller inside the
* shell plus the document's own — wp-admin grows `#wpwrap` to the admin menu's
* height — latch a wheel gesture one at a time, so scrolling stalls at
* whichever end it reaches first. Below `$break-medium` boot fixes its own
* surfaces.
*/
@media (min-width: #{breakpoints.$break-medium + 1}) {

.boot-layout-container .boot-layout.boot-layout--single-page {
position: static;
block-size: auto;
}

.boot-layout__surfaces,
.boot-layout__stage {
block-size: auto;
overflow: visible;
}

// admin-ui pins the Page header at 0, which the admin bar then covers.
.boot-layout__stage > .admin-ui-navigable-region > :first-child {
inset-block-start: var(--wp-admin--admin-bar--height, #{vars.$admin-bar-height});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import apiFetch from '@wordpress/api-fetch';
import { store as bootStore } from '@wordpress/boot';
import { dispatch } from '@wordpress/data';
import { chartBar } from '@wordpress/icons';
/**
* Internal dependencies
*/
import './admin-shell.scss';

// apiFetch middleware registers onto a shared, process-wide chain. Guard so
// repeated init() calls (re-mount, HMR, a future second boot) don't stack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Flex column so the section panel fills the remaining viewport height and
// scrolls internally instead of collapsing to its content height. Otherwise
// the panel grows with the widget grid, and the grid (fixed row height)
// resizes it back, so the two oscillate while resizing a widget (flicker).
@use "@wordpress/base-styles/breakpoints";

.root {
display: flex;
flex-direction: column;
flex: 1 1 auto;
min-block-size: 0;

// The section's scroll container. Scrolling here rather than the boot
// stage keeps the page header out of the scroll flow entirely: `Page` is
// `height: 100%`, so a sticky header inside it runs out of containing
// block one viewport in and slides away. The tab list scrolls away with
// the content, which is interim until the sections move into `Page`'s
// navigation slot (WordPress/gutenberg#79746, not yet in
// `@wordpress/admin-ui`; WOOA7S-1931).
// Below `$break-medium` boot fixes its surfaces to the viewport, so the
// panel has to scroll itself; on desktop the page is the only scroller
// (WOOA7S-1991). The tab list scrolls away either way, until the sections
// move into `Page`'s navigation slot (WordPress/gutenberg#79746; WOOA7S-1931).
overflow-y: auto;

// Own stacking context, so in-panel layers (the sticky section header,
// widget focus rings) never compete with the page header above.
position: relative;
z-index: 0;

@media (min-width: #{breakpoints.$break-medium + 1}) {
min-block-size: auto;
overflow-y: visible;
}
}

// Scoped under the root to outweigh the shared tab bar's own single-class rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export { useActiveSection } from './use-active-section';
export { useDashboardGridSettings } from './use-dashboard-grid-settings';
export { useDashboardSectionLayout } from './use-dashboard-section-layout';
export { useDashboardSections } from './use-dashboard-sections';
export { usePinnedHeaderOffset } from './use-pinned-header-offset';
export { useSectionDateFilter } from './use-section-date-filter';
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useLayoutEffect } from 'react';
import styles from '../stage.module.scss';

const CUSTOM_PROPERTY = '--pa-pinned-header-block-size';

/**
* Publishes the pinned page header's height for the section header to rest below.
*
* The page scrolls, so both bands pin against the viewport and would otherwise
* overlap. The height is admin-ui's to decide and changes when the subtitle
* wraps, so it is measured rather than restated here.
*
* @param sectionHeader - The section header element, used to reach the page.
*/
export function usePinnedHeaderOffset( sectionHeader: HTMLElement | null ) {
useLayoutEffect( () => {
const page = sectionHeader?.closest< HTMLElement >( `.${ styles.dashboard }` );
const header = page?.firstElementChild;

if ( ! page || ! header ) {
return;
}

const observer = new ResizeObserver( () => {
page.style.setProperty( CUSTOM_PROPERTY, `${ header.getBoundingClientRect().height }px` );
} );
observer.observe( header );

return () => {
observer.disconnect();
page.style.removeProperty( CUSTOM_PROPERTY );
};
}, [ sectionHeader ] );
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@use "@wordpress/base-styles/breakpoints";
@use "@wordpress/base-styles/variables" as vars;

.dashboard {
min-block-size: 0;

Expand Down Expand Up @@ -105,12 +108,18 @@
}

.sectionHeader {
// Pins at 0 rather than under the page header's height: the scroll
// container is the sections root, which begins where the page header ends.
// Pins at 0 while the sections root is the scroll container, which begins
// where the page header ends. On desktop the page scrolls instead, so the
// band has to clear the admin bar and the page header pinned above it
// (published by `usePinnedHeaderOffset`).
position: sticky;
inset-block-start: 0;
z-index: 1;

@media (min-width: #{breakpoints.$break-medium + 1}) {
inset-block-start: calc(var(--wp-admin--admin-bar--height, #{vars.$admin-bar-height}) + var(--pa-pinned-header-block-size, 0px));
}

/*
* A stuck header must be opaque, and it takes the page header's fill: this
* band is page chrome, not the widgets' canvas, and the hairline is the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
useDashboardGridSettings,
useDashboardSectionLayout,
useDashboardSections,
usePinnedHeaderOffset,
useSectionDateFilter,
} from './hooks';
import styles from './stage.module.scss';
Expand Down Expand Up @@ -185,6 +186,7 @@ function Dashboard(): JSX.Element {

// Container element for the date filters panel responsive layout.
const [ containerElement, setContainerElement ] = useState< HTMLDivElement | null >( null );
usePinnedHeaderOffset( containerElement );

// The sections carry each section's default layout, so until the entity
// resolves the layout above is transiently empty. WidgetDashboard treats an
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/wooa7s-1991
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Premium Analytics: fix scrolling on the dashboard when the wp-admin menu is taller than the window.
4 changes: 4 additions & 0 deletions projects/plugins/premium-analytics/changelog/wooa7s-1991
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix scrolling on the dashboard when the wp-admin menu is taller than the window.
Loading