Skip to content

Commit 7884629

Browse files
committed
fix(panel-tabs): forward the PanelTabs and PanelTab refs on React 18
PanelTabs and PanelTab read `ref` from their props, which only React 19 passes to a function component. On React 18, which the peer range allows, the ref was dropped with a warning, so a host could not reach the row or a tab's root. Wrap both in forwardRef so the refs land on both versions.
1 parent 7ac7601 commit 7884629

2 files changed

Lines changed: 347 additions & 328 deletions

File tree

‎src/ui/panel-tabs.test.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,16 @@ describe("PanelTabs", () => {
201201
expect(document.activeElement).toBe(tab(host, "Draft"));
202202
});
203203

204-
test("host props cannot unlink a tab, and ref lands on its root", () => {
204+
test("host props cannot unlink a tab, and refs land on the row and the tab's root", () => {
205+
const rowRef = createRef<HTMLDivElement>();
205206
const rootRef = createRef<HTMLDivElement>();
206207
const host = mount(
207-
<PanelTabs label="Open items" value="a" onValueChange={() => {}}>
208+
<PanelTabs
209+
ref={rowRef}
210+
label="Open items"
211+
value="a"
212+
onValueChange={() => {}}
213+
>
208214
<PanelTab
209215
value="a"
210216
ref={rootRef}
@@ -220,6 +226,7 @@ describe("PanelTabs", () => {
220226
expect(button.getAttribute("aria-selected")).toBe("true");
221227
expect(button.parentElement).toBe(rootRef.current);
222228
expect(button.parentElement?.dataset["slot"]).toBe("panel-tab");
229+
expect(rowRef.current).toBe(host.querySelector("[role='tablist']"));
223230
});
224231

225232
test("closing the last tab sends focus to the +", () => {

0 commit comments

Comments
 (0)