Repository navigation
Keep the API Copy page menu on screen on phones - #4965
Conversation
… screen The Copy page menu was an absolutely positioned details panel. On a phone it ran off the right edge, and nothing flipped or shifted it. Copy page, the spec download, the API hub menu and the "more" chip menus are now popovers that floating.ts places beside their button. The popover draws in the top layer, so no ancestor can clip it, and the browser handles click outside and Escape. This deletes the hand-rolled positionMenu in chip-row.ts, the api-menu.ts module that floating.ts generalises, and an unused copy of the page-actions CSS. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ca03c92b # Conflicts: # tests/Elastic.ApiExplorer.Tests/.snapshots/PageActionsRenderingTests/Render_SplitButton_CopiesPageAndOpensMarkdown.verified.html # tests/Elastic.ApiExplorer.Tests/.snapshots/PageActionsRenderingTests/Render_WithSpec_ListsJsonAndYamlDownloads.verified.html # tests/Elastic.ApiExplorer.Tests/.snapshots/PageActionsRenderingTests/Render_WithoutMarkdown_OffersTheDownloadsAlone.verified.html # tests/Elastic.ApiExplorer.Tests/.snapshots/PageActionsRenderingTests/Render_WithoutSpec_HasNoDownloads.verified.html
Main now serves API pages at /docs/api/<key>. The four page-actions snapshots keep the popover markup and take the new URLs, and the Copy page journey opens the new path. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| click ".api-page-actions-chevron" | ||
| expect visible "#api-page-actions-menu" | ||
| expect attr ".api-page-actions-chevron" aria-expanded true | ||
| expect visible find role menuitem --name "View as Markdown" |
There was a problem hiding this comment.
Severity: P3 (Low)
Add a browser-level bounds assertion for the mobile placement fix. This journey passes if the menu opens partly off-screen or centered far from the chevron, and the unit tests stub the positioning result. Check that the open menu is fully inside the 375px viewport and aligned with its trigger.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
Partly addressed in f03e04c. The journey language cannot assert a box, and its get box only writes a transcript, which a deployed-site run does not compare. So the journey keeps to open and close, and the header says so. The bounds check is now floating-placement.test.ts: the real Floating UI middleware against a 375px viewport, with Copy page's chevron at the right edge and a 273px menu. It asserts the menu stays 8px inside the screen, sits under the chevron and does not pass its right edge. A second case checks it flips above near the bottom. Removing shift fails the first and removing flip fails the second. The geometry is stubbed, so I also measured the real page in Chrome at 375, 768 and 1280px; all three stay on screen.
…ew by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…(per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…h (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…(per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ed (per review by @infra-vault-gh-plugin-prod) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| .api-page-actions-dropdown.is-open .api-page-actions-chevron-icon { | ||
| transform: rotate(180deg); | ||
| /* Without the Popover API (floating.css hides the menu) the download-only page has nothing else on it, so its links show inline in place of the button. */ | ||
| @supports not selector(:popover-open) { |
There was a problem hiding this comment.
Severity: P3 (Low)
The updated snapshot verifies the modifier class, but it cannot catch a CSS regression that hides both download links when popovers are unsupported. Add a browser-level check for the download-only fallback that verifies the trigger is hidden and both links remain visible.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
There was a problem hiding this comment.
No new test, but I ran the check you describe against the shipped CSS in Chrome. I took every rule from the built @supports not selector(:popover-open) blocks, including floating.css's [popover] { display: none }, and applied them unwrapped to a page whose menu keeps its popover attribute, so the two rules compete as they would in a browser without the API. On a download-only page the trigger is hidden and both download links are visible at 375px. On the Copy page variant the menu stays hidden. The fallback wins on specificity, since both stylesheets are unlayered. I did not add this to the repo because neither harness can turn the Popover API off. The journey language has no way to do it, and the visual suite only compares screenshots. A test would have to unwrap the rules itself, so it would re-check my emulation, not the browser. For a path only browsers older than 2024 reach, I think that is not worth a new test setup. Say so if you want one anyway.
There was a problem hiding this comment.
I don’t think a bespoke test setup is warranted for this low-severity fallback. Your check is useful evidence that the current rules produce the intended result: the download-only split control is hidden while its menu is displayed under the @supports not selector(:popover-open) fallback (api-docs.css), alongside the rule that hides [popover] elements without the API (floating.css). It isn’t durable regression coverage or a run in an unsupported browser, but given the harness limitation and the age-limited path, I wouldn’t ask you to add a custom emulation test.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4965/ |
The API Copy page menu now opens beside its chevron and stays inside the viewport on a phone. A new Floating UI controller,
floating.ts, places it and the other API menus.Affects: API reference, Site UI
Prompt summary: The Copy page dropdown mispositions itself in mobile view. The goal is one Floating UI based way to place everything that floats in the UI, replacing the duplicate implementations. This PR is the first slice: the controller and the API menus.
Why
The Copy page menu was an absolutely positioned
<details>panel withright: 0. On a phone it ran off the screen edge, and nothing flipped or shifted it. It also sat in az-index: 6stacking context, so later siblings could cover it. The frontend places floating elements four different ways, and two hand-rolled copies of the same placement math sit beside the one Floating UI user.What
One placement controller
floating.tsturns any[popover]opened by a[popovertarget]button into a menu that Floating UI places and follows.data-placementpicks the side anddata-anchornames a different anchor. It releases tracking when the menu closes or an htmx swap removes it, and it replacesapi-menu.ts.Menus moved onto it
Copy page, the spec download, the API hub menu and the "+N more" chip menus are popovers. The top layer stops ancestors from clipping them, and the browser handles click outside and Escape. The filtered union menu anchors to its search box.
Code removed
The hand-rolled
positionMenuand its scroll listeners inchip-row.ts,api-menu.ts, and an unused copy of the page-actions CSS inapi-reference.css.Out of scope: the top-bar, design-system and tooltip surfaces still use their old code. They follow in separate PRs.
Verify
The first API page request after
mise run servetakes about two minutes while the spec loads.Check on the preview