Skip to content

Commit 26e7c75

Browse files
fix(app-shell): a narrow-window toast beside the record drawer no longer covers the record's Edit and more buttons (#26426)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9KTQJ7ZVwQKvdEnGAVkSedu)_ Fixes #26418 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:窄窗口(右侧抽屉旁放不下提示)时,提示条不再只躲开抽屉自己的标题栏,而是再往下躲开抽屉里第一排按钮(记录头的「编辑」「⋯」)。 - 为什么改:1024 宽窗口里新建记录后,「创建成功」提示正好盖在「编辑」上 4 秒,用户下一步要点的按钮点不到。 - 风险与回滚:只动 `ConsoleToaster.tsx` 的窄窗口分支;宽窗口(提示放在抽屉左侧)不变。回滚即还原这一个文件。 - 先看:`ConsoleToaster.tsx` 的 `firstControlRowBottom` / `clearanceFor`;`ConsoleToaster.drawerActionsRow-26418.test.tsx`。 - 两分钟验证:把浏览器窗口拉到约 1024 宽,打开任一对象,新建 → 创建;预期提示出现在「编辑」按钮下方,不挡「编辑」和「⋯」。 - 需要你做的:无,席位落地。 ## What changes `ui/packages/app-shell/src/chrome/ConsoleToaster.tsx`, the objectui#11685 fallback (no room for a toast beside an open right-edge drawer): the toaster used to drop below the drawer's own header only, so on a 1024px window with the 720px record drawer the create-success toast sat at y 69–123 on top of the record header's Edit (93–129) and ⋯ menu. It now drops below the drawer's **first row of controls** too. - The row is measured, not assumed: the topmost visible control in the drawer outside its header (`button`, `a[href]`, form fields, and the button / link / menuitem / tab roles), widened by every control that overlaps it vertically (the title's star button beside a taller Edit). The toast's top is `max(header bottom, row bottom) + 24px` on desktop and `+ 16px` on phones, where sonner spans the toaster across the window and the same row was covered. - Positions are layout offsets summed up the `offsetParent` chain, like the existing header measurement: the slide-in transform does not skew them, and `offsetTop` ignores the body's scroll position, so a toast raised mid-scroll still clears the row once the user scrolls back (measured in Chromium, below). - A control hidden with `display: none` (no `offsetParent`) does not count. A first control in the drawer's lower half is body or footer content, not a header row, so it does not count either: dropping below it would push the toast off the window. - The record renders after the drawer opens, so the hook now also observes each open drawer's subtree (`childList`) and re-measures when the row arrives, coalesced to one measurement per animation frame as before. - Wide windows are unchanged: the toast stays in the strip left of the drawer (objectui#11685). **Why measuring, not the drawer's bottom-right corner.** The card offered both. The bottom-right corner of the record drawer is where `InlineEditSaveBar` sticks (`sticky bottom-0`, Save / Cancel right-aligned), and a failed inline save raises its error toast exactly while that bar is up, so the corner option would move the same defect onto Save. It would also flip the toaster to a bottom anchor, the corner objectui#7482 keeps toasts out of. Measuring the first control row carries no page-specific pixel and follows whatever the drawer holds. ## Tests New `ConsoleToaster.drawerActionsRow-26418.test.tsx` (happy-dom; sizes assigned from the card's Chromium reading, as `ConsoleToaster.drawerClearance-11685` does): - 1024px window, 720px drawer: the toast's rect does not intersect the Edit / ⋯ row; desktop and phone offsets sit below the row. - Control: 1440px window, 864px drawer keeps the toast beside the drawer (`--offset-right: 888px`, `--offset-top: 24px`). - A record header appended after the drawer opened still moves the toast. - A hidden control and a control in the drawer's lower half do not move the toast; the same drawer with a real header row then does (non-vacuity). No existing test was edited. **Ablation 1, the fix reverted** (the whole source file restored from the merge base `436d2840`, blob `252cf760`, then restored to HEAD blob `24ccab6c`, `git diff HEAD` empty): the new file goes 3 failed / 1 passed. The three cases above the control go red; the wide-window control stays green, as a control should. `drawerClearance-11685` stays 6/6 green both ways. **Ablation 2, the drawer-subtree observer removed** (`scripts/ablation-replace.mjs`, anchor 1 → 0, restored blob == HEAD): the late-render case and the non-vacuity leg go red (2 failed / 2 passed), so the observer is load-bearing. ## Acceptance notes - Real-layout reading, Chromium 1024×768 and 1440×768, the actual `ConsoleToaster` (bundled from source) over a hand-built drawer shaped like `NavigationOverlay` (45px header, scrolling body, record header with Edit and ⋯ arriving after the drawer opened). It is a one-off probe and nothing re-runs it. - Merge base, 1024 / 720: toast 644–1000 × 69–123, which is the card's reading exactly. It covers Edit, and `elementFromPoint` at Edit's centre is the toast. - This branch, 1024 / 720: toast 644–1000 × 129–183, clear of Edit (69–105 in the probe) and ⋯. `elementFromPoint` at Edit's centre is Edit. The same reading holds with the body scrolled 60px when the toast is raised. - Both, 1440 / 864: toast 195–551 × 24–78, beside the drawer, unchanged. - In a drawer whose first control is a form field (a form sheet), the toast now sits below that first field's row instead of on it. Neither placement is a header row, and this card does not change that case. - The probe did not run the full Console with a backend. The two-minute check in the summary above is that reading. ## Verification Local, at head `e8590370`: - `pnpm exec vitest run packages/app-shell/src/chrome/ConsoleToaster packages/app-shell/src/chrome/consoleToasterAnchor` (from `ui/`, under the verify lock): 5 files / 21 tests passed. - `pnpm --filter @object-ui/app-shell type-check` (both `tsc` passes, after building the `^...` closure): exit 0. `tsconfig.test.json` includes `src/**/*.test.tsx`, so the new test is compiled. - `eslint` over the two touched files: exit 0. - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`: 34 derived families, each run with its exit captured before any pipe: 34 exit 0. `--ran` reconciliation: "34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN" (a derived zero, every line carries its exit code). The full app-shell suite and every repo-wide family are left to CI (`Test UI`, `Type Check UI`, `Lint UI`, `Lint & Repo Gates`). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No spec change.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; eslint passes on the touched files. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the maintainer summary is in Chinese by AGENTS.md's communication rule). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmQQBJvECrfY7vVyetV --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmQQBJvECrfY7vVyetV)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 75afeff commit 26e7c75

3 files changed

Lines changed: 279 additions & 7 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): on a narrow window, a toast raised beside the record drawer no longer covers the record's Edit and ⋯ buttons
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
When a right-edge drawer is open and the window is too narrow for a toast beside it (a 720px record drawer on a 1024px window, a split screen, a phone), the console's toaster drops below the drawer's header. It cleared only the drawer's own header, so the success toast raised by creating a record sat on the record header's Edit button and ⋯ menu for its whole four seconds. The toast now also drops below the drawer's first row of controls, measured from the drawer's layout, so it clears the record's actions row for any drawer content. Wide windows keep the toast in the strip beside the drawer, as before.
11+
12+
What to do: nothing.
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack#26418 — on a window too narrow for a toast beside the record
11+
* drawer (1024px window, 720px drawer), the success toast cleared only the
12+
* drawer's own header and landed on the record's Edit and ⋯ buttons right
13+
* under it, for its whole 4s life.
14+
*
15+
* The fallback now drops below the drawer's first row of controls too. This
16+
* file pins that: in the card's case the toast's rect stays off the actions
17+
* row; the wide-window case keeps objectui#11685's beside-the-drawer
18+
* placement; a row that renders after the drawer opens still moves the toast;
19+
* and controls that are not a header row (hidden, or down in the drawer's
20+
* lower half) do not.
21+
*
22+
* ⚠️ As in `ConsoleToaster.drawerClearance-11685`, happy-dom has no layout
23+
* engine: every size here is assigned, not measured. The numbers are the
24+
* card's Chromium reading of the record drawer at 1024×768: drawer header
25+
* 0–45, Edit at 93–129, toast 54px tall.
26+
*/
27+
import '@testing-library/jest-dom/vitest';
28+
import * as React from 'react';
29+
import { describe, it, expect, afterEach } from 'vitest';
30+
import { render, act, cleanup, waitFor } from '@testing-library/react';
31+
import { toast } from 'sonner';
32+
import { ConsoleToaster } from './ConsoleToaster.js';
33+
import { ThemeProvider } from './ThemeProvider.js';
34+
35+
const VIEWPORT_HEIGHT = 768;
36+
const DRAWER_HEADER_HEIGHT = 45;
37+
/** The record's actions row (Edit, ⋯), as the card measured it. */
38+
const ACTIONS_ROW = { top: 93, bottom: 129 };
39+
/** sonner's toast width, and the toast height the card measured. */
40+
const TOAST = { width: 356, height: 54 };
41+
42+
const RIGHT_SHEET = 'position: fixed; top: 0px; right: 0px; bottom: 0px;';
43+
44+
const mounted: HTMLElement[] = [];
45+
const innerWidthDescriptor = Object.getOwnPropertyDescriptor(window, 'innerWidth');
46+
47+
function setViewportWidth(width: number) {
48+
Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: width });
49+
}
50+
51+
function layout(el: HTMLElement, box: { offsetParent?: Element | null; offsetTop?: number; offsetHeight?: number }) {
52+
for (const [key, value] of Object.entries(box)) Object.defineProperty(el, key, { configurable: true, value });
53+
}
54+
55+
/**
56+
* A right-edge drawer shaped like `NavigationOverlay`'s: a header block holding
57+
* the `aria-labelledby` title and the expand/close buttons, then a scrolling
58+
* body. The drawer is fixed, so it is every descendant's `offsetParent`.
59+
*/
60+
function mountDrawer(width: number): { drawer: HTMLElement; body: HTMLElement } {
61+
const n = mounted.length;
62+
const drawer = document.createElement('div');
63+
drawer.setAttribute('role', 'dialog');
64+
drawer.setAttribute('data-state', 'open');
65+
drawer.setAttribute('aria-labelledby', `drawer-title-${n}`);
66+
drawer.setAttribute('style', RIGHT_SHEET);
67+
const header = document.createElement('div');
68+
const title = document.createElement('h2');
69+
title.id = `drawer-title-${n}`;
70+
title.textContent = 'Project';
71+
const close = document.createElement('button');
72+
close.textContent = 'Close';
73+
header.append(title, close);
74+
const body = document.createElement('div');
75+
drawer.append(header, body);
76+
layout(drawer, { offsetHeight: VIEWPORT_HEIGHT });
77+
Object.defineProperty(drawer, 'offsetWidth', { configurable: true, value: width });
78+
layout(header, { offsetTop: 0, offsetHeight: DRAWER_HEADER_HEIGHT });
79+
layout(close, { offsetParent: drawer, offsetTop: 8, offsetHeight: 28 });
80+
document.body.append(drawer);
81+
mounted.push(drawer);
82+
return { drawer, body };
83+
}
84+
85+
/**
86+
* The record's own header inside the drawer body: the title row with its
87+
* small star button, and the actions row with Edit and ⋯, taller, beside it.
88+
*/
89+
function appendRecordHeader(drawer: HTMLElement, body: HTMLElement) {
90+
const recordHeader = document.createElement('div');
91+
const star = document.createElement('button');
92+
star.setAttribute('aria-label', 'Add to favorites');
93+
const edit = document.createElement('button');
94+
edit.textContent = 'Edit';
95+
const more = document.createElement('button');
96+
more.setAttribute('aria-label', 'More');
97+
recordHeader.append(star, edit, more);
98+
layout(star, { offsetParent: drawer, offsetTop: 97, offsetHeight: 24 });
99+
layout(edit, { offsetParent: drawer, offsetTop: ACTIONS_ROW.top, offsetHeight: ACTIONS_ROW.bottom - ACTIONS_ROW.top });
100+
layout(more, { offsetParent: drawer, offsetTop: ACTIONS_ROW.top, offsetHeight: ACTIONS_ROW.bottom - ACTIONS_ROW.top });
101+
body.append(recordHeader);
102+
}
103+
104+
async function renderWithToast(): Promise<void> {
105+
render(
106+
<ThemeProvider>
107+
<ConsoleToaster />
108+
</ThemeProvider>,
109+
);
110+
act(() => {
111+
toast.success('Project created');
112+
});
113+
await waitFor(() => expect(document.querySelector('[data-sonner-toaster]')).toBeTruthy());
114+
}
115+
116+
const region = (): HTMLElement => {
117+
const el = document.querySelector<HTMLElement>('[data-sonner-toaster]');
118+
expect(el, 'sonner did not mount its toaster region').toBeTruthy();
119+
return el as HTMLElement;
120+
};
121+
122+
const px = (name: string) => parseFloat(region().style.getPropertyValue(name));
123+
124+
/** The front toast's rect, from the top-right toaster's offsets. */
125+
function toastRect() {
126+
const right = window.innerWidth - px('--offset-right');
127+
const top = px('--offset-top');
128+
return { left: right - TOAST.width, right, top, bottom: top + TOAST.height };
129+
}
130+
131+
/** The actions row's rect: Edit and ⋯ sit at the drawer's right edge, inside its 16px padding. */
132+
function actionsRowRect() {
133+
const right = window.innerWidth - 16;
134+
return { left: right - 160, right, ...ACTIONS_ROW };
135+
}
136+
137+
const intersects = (a: ReturnType<typeof toastRect>, b: ReturnType<typeof actionsRowRect>) =>
138+
a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
139+
140+
afterEach(() => {
141+
act(() => {
142+
toast.dismiss();
143+
});
144+
cleanup();
145+
for (const el of mounted.splice(0)) el.remove();
146+
if (innerWidthDescriptor) Object.defineProperty(window, 'innerWidth', innerWidthDescriptor);
147+
});
148+
149+
describe('ConsoleToaster clears the record header actions in a narrow window (objectstack#26418)', () => {
150+
it('1024px window, 720px drawer: the toast stays off the Edit / ⋯ row', async () => {
151+
setViewportWidth(1024);
152+
await renderWithToast();
153+
const { drawer, body } = mountDrawer(720);
154+
appendRecordHeader(drawer, body);
155+
await waitFor(() => expect(region().getAttribute('data-x-position')).toBe('right'));
156+
await waitFor(() => expect(px('--offset-top')).toBe(ACTIONS_ROW.bottom + 24));
157+
expect(intersects(toastRect(), actionsRowRect())).toBe(false);
158+
// Phones span the toaster across the window: it drops below the row too.
159+
expect(px('--mobile-offset-top')).toBe(ACTIONS_ROW.bottom + 16);
160+
});
161+
162+
it('the control: a wide window keeps the toast in the strip beside the drawer', async () => {
163+
setViewportWidth(1440);
164+
await renderWithToast();
165+
const { drawer, body } = mountDrawer(864);
166+
appendRecordHeader(drawer, body);
167+
await waitFor(() => expect(px('--offset-right')).toBe(888));
168+
expect(px('--offset-top')).toBe(24);
169+
expect(toastRect().right).toBeLessThanOrEqual(1440 - 864);
170+
});
171+
172+
it('a record header that renders after the drawer opens still moves the toast', async () => {
173+
setViewportWidth(1024);
174+
await renderWithToast();
175+
const { drawer, body } = mountDrawer(720);
176+
// Only the drawer's header so far: the toast sits just below it.
177+
await waitFor(() => expect(px('--offset-top')).toBe(DRAWER_HEADER_HEIGHT + 24));
178+
appendRecordHeader(drawer, body);
179+
await waitFor(() => expect(px('--offset-top')).toBe(ACTIONS_ROW.bottom + 24));
180+
});
181+
182+
it('a hidden control or one in the drawer`s lower half is not a header row', async () => {
183+
setViewportWidth(1024);
184+
await renderWithToast();
185+
const { drawer, body } = mountDrawer(720);
186+
const hidden = document.createElement('button');
187+
layout(hidden, { offsetParent: null, offsetTop: 0, offsetHeight: 0 });
188+
const footer = document.createElement('button');
189+
layout(footer, { offsetParent: drawer, offsetTop: VIEWPORT_HEIGHT - 60, offsetHeight: 36 });
190+
body.append(hidden, footer);
191+
await waitFor(() => expect(px('--offset-top')).toBe(DRAWER_HEADER_HEIGHT + 24));
192+
// Non-vacuity: the same drawer with a real header row moves the toast.
193+
appendRecordHeader(drawer, body);
194+
await waitFor(() => expect(px('--offset-top')).toBe(ACTIONS_ROW.bottom + 24));
195+
});
196+
});

‎ui/packages/app-shell/src/chrome/ConsoleToaster.tsx‎

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,32 @@ const DEFAULT_OFFSET: ToasterProps['offset'] = { top: APP_HEADER_HEIGHT + APP_HE
5050
* no part of the drawer is covered.
5151
* - Otherwise (a phone, or a drawer nearly as wide as the window) it drops
5252
* below the drawer's header, the block that carries the dialog's title and
53-
* its controls.
53+
* its controls, and below the first row of controls under that header
54+
* (objectstack#26418). In the record drawer that row is the record's own
55+
* header: Edit, the header actions and the ⋯ menu. Clearing only the
56+
* drawer's header put a 1024px window's toast straight onto Edit, the button
57+
* a user reaches for right after creating a record.
58+
*
59+
* The row is measured, not assumed: the drawer's topmost visible control
60+
* outside its header, widened by every control that overlaps it vertically
61+
* (a title's star and copy buttons beside a taller Edit). Measuring keeps the
62+
* offset right for any drawer content, without a pixel taken from one page.
63+
* A first control in the drawer's lower half is body or footer content, not a
64+
* header row, and dropping below it would push the toast off the window, so
65+
* then only the header counts. Not the drawer's bottom-right corner instead:
66+
* that is where the record's inline-edit Save / Cancel bar sticks
67+
* (`InlineEditSaveBar`), and a failed save raises its toast exactly while that
68+
* bar is up.
5469
*
5570
* "A right-edge drawer" is read off the DOM, not off a prop: an open Radix
5671
* dialog (`role="dialog"`, `data-state="open"`) laid out fixed against the
5772
* top, right and bottom edges. Every `side="right"` sheet in the console
5873
* matches, the record drawer included; popovers, centred dialogs, left and
5974
* bottom sheets do not. Its header is the dialog's top-level block that holds
6075
* its `aria-labelledby` title. Sizes are layout sizes (`offsetWidth`,
61-
* `offsetTop`), so the drawer's slide-in transform does not skew them.
76+
* `offsetTop`), so the drawer's slide-in transform does not skew them, and a
77+
* control's `offsetTop` is where it sits with the drawer scrolled to the top:
78+
* a toast raised mid-scroll still clears the row once the user scrolls back.
6279
*/
6380
const VIEWPORT_GAP = 24; // sonner's VIEWPORT_OFFSET
6481
const MOBILE_VIEWPORT_GAP = 16; // sonner's MOBILE_VIEWPORT_OFFSET
@@ -87,21 +104,62 @@ function headerOf(drawer: HTMLElement): HTMLElement | null {
87104
return block;
88105
}
89106

107+
/** What counts as a control when finding the first row of them. */
108+
const CONTROLS =
109+
'button, a[href], input, select, textarea, [role="button"], [role="link"], [role="menuitem"], [role="tab"]';
110+
111+
/**
112+
* `el`'s layout top inside `drawer`, summed up its `offsetParent` chain; null
113+
* when it is not laid out (`display: none` has no `offsetParent`) or its chain
114+
* leaves the drawer (a nested fixed layer).
115+
*/
116+
function topWithin(drawer: HTMLElement, el: HTMLElement): number | null {
117+
let top = 0;
118+
for (let node = el; node !== drawer; ) {
119+
top += node.offsetTop;
120+
const parent = node.offsetParent;
121+
if (!(parent instanceof HTMLElement) || !drawer.contains(parent)) return null;
122+
node = parent;
123+
}
124+
return top;
125+
}
126+
127+
/** The bottom of the drawer's first row of controls below its header, or 0 when there is none. */
128+
function firstControlRowBottom(drawer: HTMLElement, header: HTMLElement | null): number {
129+
const boxes: { top: number; bottom: number }[] = [];
130+
for (const el of Array.from(drawer.querySelectorAll<HTMLElement>(CONTROLS))) {
131+
if (header?.contains(el) || el.offsetHeight === 0) continue;
132+
const top = topWithin(drawer, el);
133+
if (top !== null) boxes.push({ top, bottom: top + el.offsetHeight });
134+
}
135+
boxes.sort((a, b) => a.top - b.top);
136+
const first = boxes[0];
137+
if (!first || first.top > drawer.offsetHeight / 2) return 0;
138+
let bottom = first.bottom;
139+
for (const box of boxes) {
140+
if (box.top >= bottom) break;
141+
bottom = Math.max(bottom, box.bottom);
142+
}
143+
return bottom;
144+
}
145+
90146
function clearanceFor(drawers: HTMLElement[]): DrawerClearance | null {
91147
if (drawers.length === 0) return null;
92148
let width = 0;
93-
let headerBottom = 0;
149+
let clearBelow = 0;
94150
for (const drawer of drawers) {
95151
width = Math.max(width, drawer.offsetWidth);
96152
const header = headerOf(drawer);
97-
if (header) headerBottom = Math.max(headerBottom, header.offsetTop + header.offsetHeight);
153+
if (header) clearBelow = Math.max(clearBelow, header.offsetTop + header.offsetHeight);
154+
clearBelow = Math.max(clearBelow, firstControlRowBottom(drawer, header));
98155
}
99156
const fitsBeside = window.innerWidth - width >= TOAST_WIDTH + 2 * VIEWPORT_GAP;
100157
return {
101-
offset: fitsBeside ? { right: width + VIEWPORT_GAP } : { top: headerBottom + VIEWPORT_GAP },
158+
offset: fitsBeside ? { right: width + VIEWPORT_GAP } : { top: clearBelow + VIEWPORT_GAP },
102159
// Below 600px sonner spans the toaster across the viewport, so there is
103-
// never a strip beside the drawer: always drop below its header.
104-
mobileOffset: { top: headerBottom + MOBILE_VIEWPORT_GAP },
160+
// never a strip beside the drawer: always drop below its header and its
161+
// first row of controls.
162+
mobileOffset: { top: clearBelow + MOBILE_VIEWPORT_GAP },
105163
};
106164
}
107165

@@ -111,14 +169,19 @@ function useDrawerClearance(): DrawerClearance | null {
111169
useEffect(() => {
112170
let frame = 0;
113171
const sizes = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => schedule());
172+
const contents = new MutationObserver(() => schedule());
114173
const measure = () => {
115174
frame = 0;
116175
const drawers = openRightDrawers();
117176
sizes?.disconnect();
177+
contents.disconnect();
118178
for (const drawer of drawers) {
119179
sizes?.observe(drawer);
120180
const header = headerOf(drawer);
121181
if (header) sizes?.observe(header);
182+
// The record renders after the drawer opens (its header and actions
183+
// arrive with the data), so the first control row can appear late.
184+
contents.observe(drawer, { childList: true, subtree: true });
122185
}
123186
const next = clearanceFor(drawers);
124187
// Compared by value: a fresh-but-equal object would re-render the
@@ -141,6 +204,7 @@ function useDrawerClearance(): DrawerClearance | null {
141204
if (frame) window.cancelAnimationFrame(frame);
142205
portals.disconnect();
143206
states.disconnect();
207+
contents.disconnect();
144208
sizes?.disconnect();
145209
window.removeEventListener('resize', schedule);
146210
};

0 commit comments

Comments
 (0)