Repository navigation
Let readers resize the columns on API pages - #4818
Merged
Merged
Conversation
Drag handles now sit on the edges of the sidebar and the examples rail. Arrow keys on a focused handle move the edge in 24px steps, and a double click resets the column. The widths persist in `localStorage` under `api-column-widths`. The reference column keeps at least 360px, the sidebar stops at 240px, and the handles show only on wide screens. Both the design-system layout and the legacy layout are covered. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Boosted navigation swaps the whole `.api-page-shell`. Each swap left a `window` resize listener and a `ResizeObserver` behind, and both kept the detached page alive. `initApiColumnResize` now keeps one active shell and disposes the previous one first. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Saved widths were restored with only the fixed limits, so a width saved on a wide monitor squeezed the reference column in a smaller window. The inline widths also stayed in force below the breakpoint where the handles are hidden, so a reader could not undo them. Saved widths now apply only where the handles show, shrink (rail first) until the reference keeps its 360px, and are re-fitted on resize. The stored values stay as they are for the next wide window. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4818/ |
The sidebar handle was centred on the column's right edge, so half of its 12px hit area covered the sidebar's scrollbar. Dragging the scrollbar resized the column instead of scrolling the list. The handle now starts at the edge, so its hit area sits in the gap. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The tests only moved columns by one key step well inside the available room, so a regression in the cap that keeps the reference at 360px, or in saving a drag, would still pass. New tests cover a key step and a drag that hit the cap, and a drag that saves its width only when it ends. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The design-system sidebar is 224px by default at wide windows, and the drag minimum was 240px. The first pointer move snapped the column up by 16px. The minimum for that layout now matches its stylesheet floor of 14rem. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The code samples in the rail need room, so the drag limit for the rail rises from 280px to 615px in both layouts. A rail that starts below that width snaps to 615px on the first drag. The stylesheet defaults are unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Moving the sidebar handle off the scrollbar also moved its line and bar 6px right of the sidebar's border. The handle's hit area still starts at the edge, but the line and the bar are now drawn back onto the edge, and they ignore the pointer so they cannot cover the scrollbar. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The drag minimum of the rail was above its stylesheet default (440px in the legacy layout, 320px in the design-system layout), so a double click reset the rail to a width the drag could not reach. Where the handles show, the default is now 600px. It tapers in windows too narrow to hold 600px beside a 360px reference column, so the page does not overflow. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The rail keeps its new 600px default, but the drag minimum returns to the rail's previous default: 440px in the legacy layout and 320px in the design-system layout. Readers who prefer more room for the reference can get the old layout back by dragging. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reference and the rail were capped as one block and centred beside the sidebar, so a resized column only moved space around inside that block. Up to a 1920px window the reference now takes whatever the sidebar and the rail leave. Past 1920px the columns keep the widths they have at 1920px and sit centred. In the design-system layout the page takes the wide limit on API pages, and the header follows because it shares `--layout-max`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The rail's 600px default left the reference only 484px in a 1440px window. The default now grows with the window, from the rail's previous width at the breakpoint to 600px at 1700px. At 1920px the fluid reference ran prose to about 140 characters a line, so paragraphs, lists and callouts in the reference now keep the docs text width of 48rem. Parameter rows and code still use the whole column. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The sidebar handle's hit area started at the sidebar's edge, but its bar and line are drawn centred on that edge. A double click or a drag aimed at the left half of the bar landed on the sidebar instead. The hit area now starts 3px inside the sidebar and covers the whole bar, which still leaves most of the sidebar's scrollbar clear. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`api-reference.css` must use colour roles, and the idle bar used the hex literal `#b6c0d1`, which failed `ComponentCss_ReadsTokensOnly` in `Navigation.Tests`. The bar now uses `--color-border-control`, so it also follows the theme. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The mocked column rectangles never changed, so the key-step test accepted a sidebar that grew right after the rail used up all the spare room. The mocks now read the applied `--layout-nav-width` and `--layout-rail-width`, as the real layout does, and the test expects the sidebar to stay put. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The 1920px layout set `--layout-max` on the `body` of every design-system API page. The injected elastic.co masthead follows that token, so on the assembled site the masthead and docs bar widened on API pages and snapped back on every other page. The token now changes on the shell only, and the header keeps its contained width. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
When boosted navigation replaced an API page with a regular documentation page, `initApiColumnResize` returned early without cleaning up. The observer and the window resize listener kept reconciling a detached shell until another API page opened. The early return now disposes the active shell. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`slack()` rebuilt the reference column's width from the shell's edges, so it did not see the 32px of right padding on the legacy layout's inner grid. In that layout a drag, or a restore of saved widths, left the reference at about 328px instead of 360px. It now reads the reference column's own width. The fit loop looks again after each cut, because the reference stops at zero and a window far too small for the saved widths reports only part of the shortage. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The sidebar's border is one pixel wide and ends on the column's edge, so its centre is half a pixel inside the edge. The 4px bar and the 2px line were centred on the edge, which left the border overhanging by one pixel on the left and two on the right. The sidebar handle now uses a 5px bar (7px on hover) and a 3px line, all placed on whole pixels around the border's own column. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API operation and schema pages now have drag handles on the sidebar edge and the examples rail edge, so readers can give each column the width they want. The widths persist across pages and reloads.
Affects: API reference, Site UI
Prompt summary: Make the sidebar and the examples rail on API pages resizable by dragging, and make the drag handle easy to find without adding a permanent border to the page. The choice of handle look was made by comparing several versions on a running page.
Why
The sidebar is fixed at one width and the examples rail follows a clamp, so long operation names and wide code samples wrap or clip with no way to adjust. Readers on large screens also cannot trade sidebar space for example space.
What
Drag handles
api-column-resize.tsadds one handle per column edge after the page loads. A handle moves its column with the pointer, or in 24px steps with the arrow keys when focused. A double click gives the column back to the stylesheet. Without script, the columns keep the widths the stylesheet gives them. The sidebar handle reaches only 3px back over the sidebar, so most of the sidebar's scrollbar stays clear.Limits
The sidebar ranges from 224px (240px in the legacy layout) to 560px, and the rail from its previous default (440px in the legacy layout, 320px in the design-system layout) to 900px. The rail's default grows with the window, from its previous width at the breakpoint to 600px at 1700px, and a double click resets to that default. The reference column never drops under 360px, so a column stops growing before it squeezes the content. The handles show only on wide screens: 1101px and up in the design-system layout, 1280px and up in the legacy layout.
Three columns up to 1920px
Up to a 1920px window the page is three full columns: the reference takes whatever the sidebar and the rail leave, so a drag trades space directly between a column and the reference. Past 1920px the columns keep the widths they have at 1920px and sit centred. In the design-system layout only the page shell takes the wide limit (
--layout-max-wide). The header keeps its contained width, so in windows wider than the header the sidebar starts left of the header's left edge, as it does in the legacy layout.Prose width
The reference column is fluid, so paragraphs, lists and callouts inside it keep the docs text width of 48rem. Parameter rows and code still use the whole column.
Persistence
Widths are saved in
localStorageunderapi-column-widths. A blocked or unavailable storage only means the widths are not kept. Saved widths apply only where the handles show. In a smaller window they shrink, rail first, so the reference keeps its minimum, and they come back in a wider window. The module keeps one active shell and releases the listeners of the shell that boosted navigation replaces.Handle look
Each handle is a slim 4px grey bar at the middle of the window, so it stays in reach while the page scrolls. On hover, focus or drag, the bar grows to 6px and turns accent-colored, and a 2px line shows along the full edge. Both layouts share the same shape, with each using its own accent color. In the legacy layout the sidebar's bar is 5px (7px on hover) and its line 3px, so they sit symmetrically on the sidebar's own 1px border.
Verify
The design-system layout shows with
FEATURE_NAVIGATION_PREVIEW=true mise run serve.Check on the preview
🤖 Generated with Claude Code