diff --git a/.changeset/fix-code-block-buttons-absolute.md b/.changeset/fix-code-block-buttons-absolute.md new file mode 100644 index 00000000..d794d8b5 --- /dev/null +++ b/.changeset/fix-code-block-buttons-absolute.md @@ -0,0 +1,13 @@ +--- +"streamdown": patch +--- + +fix(code-block): use absolute positioning for action buttons to fix click events in nested scroll containers + +Switches the code block action button wrapper from `position: sticky` to +`position: absolute` (with `position: relative` on the container) so that +hit-testing works correctly in layouts with multiple nested `overflow: auto` +scroll containers. Previously, the `sticky` + `pointer-events-none/auto` +pattern caused browsers to mis-route click events to the code block wrapper +rather than the buttons when the component was embedded in 2+ nested scroll +containers. diff --git a/packages/streamdown/lib/code-block/container.tsx b/packages/streamdown/lib/code-block/container.tsx index 1d2a09dd..fbd32494 100644 --- a/packages/streamdown/lib/code-block/container.tsx +++ b/packages/streamdown/lib/code-block/container.tsx @@ -18,7 +18,7 @@ export const CodeBlockContainer = ({ return (