fix: remove manual width/padding calculations from collection views#689
Open
albertodainotti wants to merge 4 commits intoNotionX:masterfrom
Open
fix: remove manual width/padding calculations from collection views#689albertodainotti wants to merge 4 commits intoNotionX:masterfrom
albertodainotti wants to merge 4 commits intoNotionX:masterfrom
Conversation
…(let css handle it)
|
@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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 of100vwfor table and board views.notion-tableand.notion-boardusedwidth: 100vw/max-width: 100vw, which made them stretch to the full viewport width, ignoring page margins. Changed towidth: 100%/max-width: 100%so they respect their parent container.3. Constrain
.notion-collectionwrapperThe
.notion-collectionwrapper had nomax-widthoroverflowconstraint, so tables with wide columns (floated content) would push it beyond the page container. Addedmax-width: 100%andoverflow: autoto keep it within bounds while enabling horizontal scroll when content is wider.4. Prevent gallery card shadow clipping
The
overflow: autoon.notion-collectionclips gallery cardbox-shadowat container edges. Addedpadding: 4pxwith compensatingmargin: -4pxto 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 fixespackages/react-notion-x/src/third-party/collection.tsx— Remove JS width calculations