Skip to content

Commit 23415c2

Browse files
authored
Merge pull request #12926 from google/enhancement/12722-thumbs-feedback-a11y-popper
Slide the Site Goals thumbs popper under the top nav on scroll
2 parents 546a44f + b49c42a commit 23415c2

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

assets/js/googlesitekit/components-gm2/Popper.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,19 @@ describe( 'Popper', () => {
153153
);
154154
} );
155155

156+
it( 'renders the popper content inside the popper root element', async () => {
157+
const { container, findByRole } = render( <PopperWrapper /> );
158+
159+
await findByRole( 'button', { name: 'Inside' } );
160+
161+
const root = container.querySelector( '.googlesitekit-popper-root' );
162+
163+
expect( root ).not.toBeNull();
164+
expect(
165+
root?.querySelector( '.googlesitekit-popper' )
166+
).toBeInTheDocument();
167+
} );
168+
156169
describe( 'auto-dismiss', () => {
157170
beforeEach( () => {
158171
jest.useFakeTimers();

assets/js/googlesitekit/components-gm2/Popper.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export type PopperPlacement =
3939

4040
const DEFAULT_AUTO_DISMISS_MS = 4000;
4141
const DEFAULT_OFFSET = 9;
42-
const POPPER_STYLE = { zIndex: 99999 };
4342

4443
interface PopperProps {
4544
/**
@@ -164,7 +163,7 @@ const Popper: FC< PopperProps > = ( {
164163
open={ hasAnchorElement }
165164
anchorEl={ anchorElement }
166165
placement={ placement }
167-
style={ POPPER_STYLE }
166+
className="googlesitekit-popper-root"
168167
// MUI Popper sets `role="tooltip"` by default. Clear it because this is a notification panel, not a tooltip.
169168
role={ undefined }
170169
modifiers={ {

assets/sass/components/analytics-4/site-goals/_googlesitekit-site-goals-selection-panel.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
flex: 1 1 auto;
3333
min-height: 0;
3434
overflow-y: auto;
35+
36+
// When the user scrolls the panel, the thumbs feedback tooltip can slide
37+
// up over the panel header or down over the footer. The panel content
38+
// uses `position: relative` so it hides any part of the tooltip that
39+
// passes its edges, and the tooltip stays inside.
40+
position: relative;
3541
}
3642

3743
.googlesitekit-site-goals-selection-panel__footer-container {

assets/sass/components/global/_googlesitekit-popper.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
* limitations under the License.
1717
*/
1818

19+
.googlesitekit-popper-root {
20+
// The popper renders next to its anchor, not at the document root, so its
21+
// z-index competes only with nearby elements in the same stacking context,
22+
// not with the global `$z-index-sk-*` scale (9970 and up). This value sits
23+
// above the Site Goals charts (8) and below the dashboard navigation (10),
24+
// so the popper slides under the top nav on scroll instead of covering it.
25+
// The entity header uses the same value for the same reason.
26+
z-index: $z-index-sk-popper;
27+
}
28+
1929
.googlesitekit-popper {
2030
background-color: $c-surfaces-on-surface;
2131
border-radius: 4px;

assets/sass/config/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ $z-index-sk-side-sheet: 10000;
339339
$z-index-sk-side-sheet-overlay: 9990;
340340
$z-index-sk-header: 9980;
341341
$z-index-sk-overlay-notification: 9970;
342+
$z-index-sk-popper: 9;
342343
$z-index-sk-notice-snackbar: 9;
343344

344345
// Start Authorize Application screen specific styles.

0 commit comments

Comments
 (0)