Skip to content

fix: remove manual width/padding calculations from collection views#689

Open
albertodainotti wants to merge 4 commits intoNotionX:masterfrom
InetIntel:fix-collection-layout
Open

fix: remove manual width/padding calculations from collection views#689
albertodainotti wants to merge 4 commits intoNotionX:masterfrom
InetIntel:fix-collection-layout

Conversation

@albertodainotti
Copy link
Contributor

@albertodainotti albertodainotti commented Mar 7, 2026

Summary

Fix collection view layout to respect page content width instead of stretching to the full viewport.

Changes

1. Remove manual width/padding calculations from collection views

The original JS-based width calculation (containerWidth = window.innerWidth) caused layout issues in pages with custom max-widths. This removes the manual calculations and lets CSS handle the layout.

2. Use width: 100% instead of 100vw for table and board views

.notion-table and .notion-board used width: 100vw / max-width: 100vw, which made them stretch to the full viewport width, ignoring page margins. Changed to width: 100% / max-width: 100% so they respect their parent container.

3. Constrain .notion-collection wrapper

The .notion-collection wrapper had no max-width or overflow constraint, so tables with wide columns (floated content) would push it beyond the page container. Added max-width: 100% and overflow: auto to keep it within bounds while enabling horizontal scroll when content is wider.

4. Prevent gallery card shadow clipping

The overflow: auto on .notion-collection clips gallery card box-shadow at container edges. Added padding: 4px with compensating margin: -4px to give shadows room to render.

Before / After

Before: Table views span full viewport width, ignoring page margins.
After: Table views respect page content width (same as galleries), with horizontal scroll for wide content.

Files Changed

  • packages/react-notion-x/src/styles.css — CSS layout fixes
  • packages/react-notion-x/src/third-party/collection.tsx — Remove JS width calculations

@vercel
Copy link

vercel bot commented Mar 7, 2026

@albertodainotti is attempting to deploy a commit to the Saasify Team on Vercel.

A member of the Team first needs to authorize it.

Tables and boards were using 'width: 100vw' which forced them to span
the full viewport, breaking page container margins. Changed to 100% so
they respect their parent container's width while still scrolling
horizontally via 'overflow: auto hidden' when content overflows.
The .notion-collection wrapper had no max-width or overflow constraint,
so tables with wide columns (floated content) would push it beyond the
page container. Adding max-width: 100% and overflow: auto keeps it
within bounds while enabling horizontal scroll.
The overflow:auto clips gallery card box-shadows at the edges.
Adding padding with compensating negative margin gives shadows
room to render without shifting the layout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant