Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
00c8186
Delete the unused _NavSelect partial and its menu styles
reakaleek Nov 19, 2026
e84629b
Delete the unreachable top-bar section dropdown
reakaleek Nov 19, 2026
1670471
Open data-hover menus on mouse hover and close menus after a link
reakaleek Nov 19, 2026
3f7090b
Open the sidebar section menu as a popover beside its box
reakaleek Nov 19, 2026
734b4a1
Show the page jumper's results in a popover under its field
reakaleek Nov 19, 2026
9656f0d
Open every design-system menu as a popover placed by floating.ts
reakaleek Nov 19, 2026
9e8b526
Describe the one menu pattern in the design-system docs
reakaleek Nov 19, 2026
b47d600
Keep a hovered menu open when its button is clicked
reakaleek Nov 19, 2026
d6787a3
Merge remote-tracking branch 'origin/main' into floating-menus-everyw…
reakaleek Nov 19, 2026
0d24df4
Target the version menu button in the API browse journey
reakaleek Nov 19, 2026
2d94649
Rebind applies-to badges in the fullscreen table copy
reakaleek Nov 19, 2026
ac929a2
Hold hover timers and hover state weakly in floating.ts
reakaleek Nov 19, 2026
d96b1f9
Reopen a hover menu only when the pointer arrives from outside
reakaleek Nov 19, 2026
5f0544e
Close a menu when one of its links is middle-clicked
reakaleek Nov 19, 2026
309650b
Drop aria-haspopup="menu" from the link-list disclosures
reakaleek Nov 19, 2026
dc7ec74
Let a click focus the unbound applies-to badge in Safari
reakaleek Nov 19, 2026
e100889
Reset aria-expanded on an unbound applies-to clone
reakaleek Nov 19, 2026
f74cc23
Release popover tracking when the fullscreen table closes
reakaleek Nov 19, 2026
ddccc5a
Merge remote-tracking branch 'origin/main' into resolve-pr-comments-4…
reakaleek Nov 19, 2026
da45d67
Release removed popovers in the swap-time sweep again
reakaleek Nov 19, 2026
63a5219
Cancel the hover-close timer when a popover closes
reakaleek Nov 19, 2026
7401748
Drop aria-haspopup="menu" from deployment info and the split button
reakaleek Nov 19, 2026
489f874
Drop aria-haspopup="dialog" from the theme switch cog
reakaleek Nov 19, 2026
73ae94f
Leave aria-expanded on popover buttons to the browser
reakaleek Nov 19, 2026
37f4a36
Stop announcing the applies-to panel as a dialog
reakaleek Nov 19, 2026
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
9 changes: 6 additions & 3 deletions docs/development/design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,19 @@ These replace React components built on EUI. Each renders complete markup on the

| Piece | Replaces | How it works |
|---|---|---|
| Applies-to badge | `applies-to-popover` | A native `details` element holds the panel. Script moves the open panel into the browser's top layer, next to its trigger, so no ancestor can clip it |
| Applies-to badge | `applies-to-popover` | A button and a panel. `Assets/ds/applies-popover.ts` gives the panel an id and makes it a popover the button opens, in the browser's top layer, so no ancestor can clip it. Unbound, the panel shows while the button has focus |
| Search | The modal search in the header | A native `dialog`, opened by the header field or `Ctrl+K`. Isolated builds query the Pagefind index and assembled builds query the search API. Results are drawn from a template, and highlights are built from text nodes |
| Page feedback | `page-feedback` | The server renders the whole widget, hidden. Script reveals it, keeps a draft in `sessionStorage` and sends the same payload as before |
| Version and section pickers | `version-dropdown` | A native `details` menu of plain links |
| Version and section pickers | `version-dropdown` | A link menu: a button that opens a popover of plain links |
| Vector sizing calculator | `vector-sizing-calculator` | The server renders the whole form, hidden, with native inputs, `datalist` presets and a `details` for advanced settings. `Assets/ds/vector-sizing.ts` reveals it and reuses the existing calculation modules for the arithmetic |
| Ask AI | The React assistant | A button and a native `dialog` side panel. `Assets/ds/ask-ai.ts` streams the answer from the same endpoint as before and renders it as sanitized Markdown. Shown on assembler and Codex pages. Suggestions come from the existing assistant configuration, the conversation is kept in session storage, rate limits are explained, answers list their references, and thumbs feedback is sent to the existing endpoint |
| Overlays | EUI tooltips, toasts and flyouts | `Tooltip` needs no script. `Toast` and `Flyout` reveal their dismiss and open buttons from script. `Banner`, `Skeleton` and `EmptyState` are plain markup |
| Section bar | The secondary navigation | A server-rendered docs bar. The elastic.co header on assembled sites is still loaded by script from elastic.co |

The server renders each of these without the legacy custom elements, so a flag-on page loads no EUI components.

Every menu, in both layouts, is a `button[popovertarget]` that opens a `[popover]`. The browser draws it in the top layer and closes it on Escape and a click outside. `Assets/floating.ts` places it beside its button with Floating UI, flips and shifts it to stay on screen, and closes it on a page swap or after a link in it is chosen. `data-placement` picks the side, `data-anchor` names another anchor, and `data-hover` also opens the menu while a mouse rests on it. A menu rendered more than once on a page takes its id from its model.

## Layers

The design system declares its cascade layers under a `ds` namespace so they never merge with other stylesheets' layers. The order lives in `Assets/ds-layers.css`, which must load before `ds.css`:
Expand Down Expand Up @@ -210,7 +212,8 @@ To write your own theme, load a stylesheet after `ds.css` that overrides roles.
The design-system stylesheets target Chrome and Edge 111, Firefox 113 and Safari 16.2 or later.
The bundle sets this floor in the `ds-css` and `ds-guide-css` targets in `package.json`.
The floor is set by `color-mix()`, which has no fallback.
`:has()`, container queries and popovers enhance the page where the browser has them and fall back to a simpler layout where it doesn't.
`:has()` and container queries enhance the page where the browser has them and fall back to a simpler layout where it doesn't.
Menus need the Popover API, which Safari has from version 17. Without it a menu stays closed, the link menu shows its links inline, and the applies-to panel shows while its badge has focus.

## Heroes, backgrounds and the call to action

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div id="api-version-switcher">
@await RenderPartialAsync(_LinkMenu.Create(new LinkMenuModel
{
Id = "api-version-menu",
Comment thread
infra-vault-gh-plugin-prod[bot] marked this conversation as resolved.
Resolved
Label = "API version",
Items = [.. apiContext.Versions.Select(item => new LinkMenuItem(item.Label, item.Value, item.Selected))]
}))
Expand All @@ -19,6 +20,7 @@
{
@await RenderPartialAsync(_LinkMenu.Create(new LinkMenuModel
{
Id = "api-product-menu",
Label = "API product",
Items = [.. apiContext.ProductGroups.SelectMany(group => group.Products).Select(item => new LinkMenuItem(item.Label, item.Url, item.Selected))]
}))
Expand Down
8 changes: 2 additions & 6 deletions src/Elastic.Documentation.Site/Assets/ds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { bindApiBetaBanner } from './api-beta-banner'
import { initApiChromeSync } from './api-chrome-sync'
import { initApiColumnResize } from './api-column-resize'
import { initAppliesPopovers } from './ds/applies-popover'
import { initAskAi } from './ds/ask-ai'
import { initCarousels } from './ds/carousel'
import { initCopyButtons, initCopyText } from './ds/copy'
Expand All @@ -12,12 +13,10 @@ import { initDocsBarSync } from './ds/docs-bar'
import { initFeedback } from './ds/feedback'
import { initLightboxes } from './ds/lightbox'
import { initListings } from './ds/listing'
import { bindOutsideClick, initMenus } from './ds/menu'
import { initNav } from './ds/nav'
import { initNavFilter } from './ds/nav-filter'
import { initFlyoutResize, initFlyouts, initToasts } from './ds/overlays'
import { initPageJumpers } from './ds/page-jumper'
import { initInlinePopovers, initPopovers } from './ds/popover'
import { initPreferences } from './ds/preferences'
import './ds/runtime'
import { bindSearchShortcut, initSearch } from './ds/search'
Expand Down Expand Up @@ -45,9 +44,7 @@ function init(scope: ParentNode = document) {
initTabSync(scope)
initCopyButtons(scope)
initCopyText(scope)
initMenus(scope)
initPopovers(scope)
initInlinePopovers(scope)
initAppliesPopovers(scope)
initFeedback(scope)
initSearch(scope)
initSearchPage(scope)
Expand All @@ -69,7 +66,6 @@ function init(scope: ParentNode = document) {
void loadStorybookStories(scope)
}

bindOutsideClick()
// The banner sits outside #main-container, so htmx:load does not reach a banner that navigation brings in.
bindApiBetaBanner((banner) => init(banner))
initDocsBarSync()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { initAppliesPopovers, unbindAppliesPopovers } from './applies-popover'

const badge = `
<span class="applies-popover" data-applies-popover>
<button type="button" data-applies-trigger>Stack 9.1+</button>
<span data-applies-panel>Details</span>
</span>`

describe('applies-to popovers', () => {
const showPopover = HTMLElement.prototype.showPopover

beforeEach(() => {
// jsdom has no popover API; the module binds only where it exists.
HTMLElement.prototype.showPopover = vi.fn()
document.body.innerHTML = badge + badge
})

afterEach(() => {
HTMLElement.prototype.showPopover = showPopover
})

const triggers = () =>
Array.from(document.querySelectorAll('[data-applies-trigger]'))
const panels = () =>
Array.from(document.querySelectorAll('[data-applies-panel]'))

it('makes each button open its own panel as a popover', () => {
initAppliesPopovers()

const [first, second] = panels()
expect(first.getAttribute('popover')).toBe('')
expect(first.id).not.toBe(second.id)
triggers().forEach((trigger, i) =>
expect(trigger.getAttribute('popovertarget')).toBe(panels()[i].id)
)
})

it('gives badges brought in by a later swap ids of their own', () => {
initAppliesPopovers()
const before = panels().map((panel) => panel.id)

document.body.insertAdjacentHTML('beforeend', badge)
initAppliesPopovers()

const added = panels()[2]
expect(before).not.toContain(added.id)
expect(
panels()
.slice(0, 2)
.map((panel) => panel.id)
).toEqual(before)
})

it('leaves the panel to show on focus where the browser has no popovers', () => {
HTMLElement.prototype.showPopover =
undefined as unknown as typeof showPopover

initAppliesPopovers()

expect(panels()[0].hasAttribute('popover')).toBe(false)
expect(
document
.querySelector('[data-applies-popover]')!
.hasAttribute('data-applies-bound')
).toBe(false)
})

it('gives a cloned badge a panel of its own once it is unbound', () => {
document.body.innerHTML = badge
initAppliesPopovers()
const original = panels()[0]
triggers()[0].setAttribute('aria-expanded', 'true')
const copy = document.createElement('div')
copy.innerHTML = document.body.innerHTML

unbindAppliesPopovers(copy)
document.body.append(copy)
initAppliesPopovers(copy)

const copied = copy.querySelector('[data-applies-panel]')!
expect(copied.id).not.toBe(original.id)
expect(
copy
.querySelector('[data-applies-trigger]')!
.getAttribute('popovertarget')
).toBe(copied.id)
expect(
copy
.querySelector('[data-applies-trigger]')!
.hasAttribute('aria-expanded')
).toBe(false)
})
})
38 changes: 38 additions & 0 deletions src/Elastic.Documentation.Site/Assets/ds/applies-popover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// The applies-to badge opens its panel as a popover: the browser opens and closes it, and floating.ts places it beside the button.
// A page renders the badge many times, from Markdown, tables and API pages that share no counter, so the server cannot give each
// panel a unique id. Binding gives it one and points the button at it. Unbound, the panel shows while the button has focus.
// Hooks: [data-applies-popover] on the wrapper, [data-applies-trigger] on the button and [data-applies-panel] on the panel.
let count = 0

export function initAppliesPopovers(scope: ParentNode = document) {
if (typeof HTMLElement.prototype.showPopover !== 'function') return
scope
.querySelectorAll<HTMLElement>(
'[data-applies-popover]:not([data-applies-bound])'
)
.forEach((root) => {
const trigger = root.querySelector('[data-applies-trigger]')
const panel = root.querySelector('[data-applies-panel]')
if (!trigger || !panel) return
panel.id = `applies-popover-${++count}`
panel.setAttribute('popover', '')
trigger.setAttribute('popovertarget', panel.id)
Comment thread
infra-vault-gh-plugin-prod[bot] marked this conversation as resolved.
Resolved
root.dataset.appliesBound = ''
})
}

/** A cloned badge carries the original's panel id and `popovertarget`, so it would open the original panel. Unbind it, then `initAppliesPopovers` binds the copy. */
export function unbindAppliesPopovers(scope: ParentNode) {
scope
.querySelectorAll<HTMLElement>('[data-applies-bound]')
.forEach((root) => {
const trigger = root.querySelector('[data-applies-trigger]')
const panel = root.querySelector('[data-applies-panel]')
panel?.removeAttribute('id')
panel?.removeAttribute('popover')
trigger?.removeAttribute('popovertarget')
// The copy's panel starts closed, whatever state the original was in.
trigger?.removeAttribute('aria-expanded')
delete root.dataset.appliesBound
Comment thread
infra-vault-gh-plugin-prod[bot] marked this conversation as resolved.
Resolved
})
}
23 changes: 1 addition & 22 deletions src/Elastic.Documentation.Site/Assets/ds/docs-bar.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { syncDocsBar } from './docs-bar'

const bar = (current: string) =>
`<nav id="docs-bar"><a href="/a" ${current === 'a' ? 'aria-current="page"' : ''}>A</a><a href="/b" ${current === 'b' ? 'aria-current="page"' : ''}>B</a><details data-menu></details></nav>`
`<nav id="docs-bar"><a href="/a" ${current === 'a' ? 'aria-current="page"' : ''}>A</a><a href="/b" ${current === 'b' ? 'aria-current="page"' : ''}>B</a></nav>`

describe('docs bar sync', () => {
beforeEach(() => {
Expand All @@ -20,14 +20,6 @@ describe('docs bar sync', () => {
expect(document.querySelectorAll('#docs-bar')).toHaveLength(1)
})

it('binds the menus of the new bar', () => {
syncDocsBar(`<html><body>${bar('b')}</body></html>`)

expect(
document.querySelector('details')?.hasAttribute('data-menu-bound')
).toBe(true)
})

it('binds the theme switch of the new bar so its choices apply', () => {
const withSwitch = `<nav id="docs-bar"><div class="theme-switch"><input type="radio" name="theme" data-pref="theme" value="dark"><input type="radio" name="theme" data-pref="theme" value="light"></div></nav>`
document.documentElement.removeAttribute('data-theme')
Expand All @@ -43,19 +35,6 @@ describe('docs bar sync', () => {
expect(document.documentElement.dataset.theme).toBe('dark')
})

it('binds the popovers of the new bar so its menu is shown in the top layer', () => {
HTMLElement.prototype.showPopover = function () {}
HTMLElement.prototype.hidePopover = function () {}
const withMenu = `<nav id="docs-bar"><details data-menu data-popover><summary>Products</summary><div data-popover-panel>Menu</div></details></nav>`
syncDocsBar(`<html><body>${withMenu}</body></html>`)

expect(
document
.querySelector('[data-popover-panel]')
?.getAttribute('popover')
).toBe('manual')
})

it('leaves the bar alone when the response has none', () => {
const changed = syncDocsBar('<div>a search result</div>')

Expand Down
7 changes: 2 additions & 5 deletions src/Elastic.Documentation.Site/Assets/ds/docs-bar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { initMenus } from './menu'
import { initPopovers } from './popover'
import { initPreferences } from './preferences'

// htmx swaps #main-container and the docs bar sits above it, so after a boosted navigation the bar would keep the previous page's
Expand All @@ -13,9 +11,8 @@ export function syncDocsBar(html: string): boolean {
// A partial response, such as a search result, has no bar and leaves ours alone.
if (!next) return false
current.replaceWith(next)
// The htmx:load initializers only scan the swapped container, so the new bar's menus, their top-layer popovers and its theme switch are bound here.
initMenus(next)
initPopovers(next)
// The htmx:load initializers only scan the swapped container, so the new bar's theme switch is bound here. Its menus are popovers
// that need no binding.
initPreferences(next)
return true
}
Expand Down
89 changes: 0 additions & 89 deletions src/Elastic.Documentation.Site/Assets/ds/menu.test.ts

This file was deleted.

Loading
Loading