Stabilize embedded database layout and view switching#341
Merged
Conversation
Embedded database blocks now use a fixed 300px viewport so switching between Grid and Board tabs no longer reflows the document. Grid rows scroll inside the bounded panel, and Board card lists scroll within each Kanban column instead of overflowing. - Default fixedHeight=300 for embedded databases (DatabaseContent.tsx) - Grid virtualizer uses its own parentRef as scroll element when embedded, preventing @tanstack/react-virtual from calling scrollTo(0) on the outer page scroller on view switch - Add min-h-0 flex-1 to Grid/GridProvider/Board wrappers so children respect the bounded panel height - Remove CardList hard-coded 2000px height; fill column height via flex-1 and keep maxHeight as a safety cap - Unify database block selection highlight: paint the entire block background instead of striping just tabs and header row Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reviewer's GuideStabilizes embedded database blocks to use a fixed-height (300px) internal scroll viewport, ensures Grid/Board views share consistent flexbox/min-height behavior, corrects the virtualizer scroll element for embedded vs full-page databases, and simplifies block-selection styling so the entire database block is highlighted uniformly. Sequence diagram for selecting scroll element in useGridVirtualizersequenceDiagram
participant GridVirtualizer
participant useGridVirtualizer
participant parentRef
participant ScrollContainer
GridVirtualizer->>useGridVirtualizer: useGridVirtualizer({ data, columns })
useGridVirtualizer->>parentRef: getScrollElement()
alt [isDocumentBlock]
useGridVirtualizer->>ScrollContainer: return parentRef.current
else [not isDocumentBlock]
useGridVirtualizer->>ScrollContainer: parentRef.current.closest(appflowy-scroll-container)
Note over useGridVirtualizer,ScrollContainer: Fallback to getScrollParent(parentRef.current) if no closest()
end
Flow diagram for embedded database fixed-height layoutflowchart TD
DatabaseContent[DatabaseContent\nfixedHeight = 300]
GridProvider[GridProvider\nclass: flex min-h-0 flex-1 flex-col]
Grid[Grid\n.database-grid min-h-0 flex-1 flex-col]
GridVirtualizer[GridVirtualizer\nappflowy-custom-scroller\nmin-h-0 flex-1 when embedded]
CardList[CardList\nappflowy-custom-scroller\nmin-h-0 flex-1\nmaxHeight = 2000]
DatabaseContent --> GridProvider
GridProvider --> Grid
Grid --> GridVirtualizer
GridVirtualizer --> CardList
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
CARD_LIST_MAX_HEIGHTmagic value is still baked intoCardListas both a constant and a maxHeight cap; consider either deriving it from layout context or centralizing it with other layout constants so changing embedded sizing doesn’t require hunting down multiple hard-coded values. - The default
EMBEDDED_DATABASE_FIXED_HEIGHT = 300is now applied any timefixedHeightis omitted; if some embedded usages relied on the previous 'auto' behavior, you may want to make this default opt-in via the caller or a feature flag instead of enforcing it at the component level.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `CARD_LIST_MAX_HEIGHT` magic value is still baked into `CardList` as both a constant and a maxHeight cap; consider either deriving it from layout context or centralizing it with other layout constants so changing embedded sizing doesn’t require hunting down multiple hard-coded values.
- The default `EMBEDDED_DATABASE_FIXED_HEIGHT = 300` is now applied any time `fixedHeight` is omitted; if some embedded usages relied on the previous 'auto' behavior, you may want to make this default opt-in via the caller or a feature flag instead of enforcing it at the component level.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
Root causes addressed
@tanstack/react-virtual's Grid virtualizer was resolving its scroll element to the outer page scroller via.closest('.appflowy-scroll-container'). On view switch it calledscrollTo(0)on the document, kicking the user to the top.GridProvider,.database-grid, grid scroller) were missingmin-h-0, so children withflex-1grew to content size and overflowed the 300px panel (clipped byoverflow-hidden).CardListhad a hard-codedheight: 2000pxthat ignored the column's available height..database-tabs, .grid-row-filed-cell, .column, producing a partial stripe.Test plan
🤖 Generated with Claude Code
Summary by Sourcery
Stabilize embedded database layout and scrolling behavior for grid and board views to prevent page jumps and ensure consistent block highlighting.
New Features:
Bug Fixes:
Enhancements: