Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/fix-fullscreen-copy-download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"streamdown": patch
---

fix(table): add `data-streamdown="table-wrapper"` to fullscreen portal so copy/download dropdowns can find the table
23 changes: 23 additions & 0 deletions packages/streamdown/__tests__/table-fullscreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,27 @@ describe("TableFullscreenButton", () => {
const copyBtn = overlay?.querySelector('button[title="Copy table"]');
expect(copyBtn).toBeFalsy();
});

it('should have data-streamdown="table-wrapper" inside fullscreen overlay so copy/download can find the table', () => {
const { container } = render(<Streamdown>{markdownWithTable}</Streamdown>);

const btn = container.querySelector(
'button[title="View fullscreen"]'
) as HTMLButtonElement;
fireEvent.click(btn);

const overlay = document.querySelector(
'[data-streamdown="table-fullscreen"]'
);
// The inner wrapper must have data-streamdown="table-wrapper" so that
// TableCopyDropdown and TableDownloadDropdown can call .closest() to find the table
const tableWrapper = overlay?.querySelector(
'[data-streamdown="table-wrapper"]'
);
expect(tableWrapper).toBeTruthy();

// And the actual table must be queryable from within the wrapper
const table = tableWrapper?.querySelector('[data-streamdown="table"]');
expect(table).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions packages/streamdown/lib/table/fullscreen-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const TableFullscreenButton = ({
{/* biome-ignore lint/a11y/noStaticElementInteractions: "div with role=presentation is used for event propagation control" */}
<div
className={cn("flex h-full flex-col")}
data-streamdown="table-wrapper"
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => e.stopPropagation()}
role="presentation"
Expand Down
Loading