Place balloons against unclipped anchor bounds - #1024
Conversation
Both anchor capture sites read `boundsInWindow()`, which clips: an anchor scrolled out of a `Modifier.verticalScroll` column (clipped rather than disposed, unlike a `LazyColumn` item) collapses to `Rect.Zero`, so the balloon was placed against the window origin — the arrow jumping to the top-left corner reported in #1022. The "anchor left the window" dismissal never fired either, because it skipped empty rects. `toBalloonAnchor()` now maps the anchor's own four corners through `localToWindow` for the real rect, and reads the clipped rect only for the separate verdict on whether the anchor is still on screen. That verdict also covers an anchor clipped away inside the window, which the old window-coordinate comparison could not see at all, so it replaces it. Dismissal is latched on an anchor that has been seen: `AnimatedVisibility` with `expandVertically()` clips its content to nothing on the frame it starts, and a balloon shown in that frame must wait for its anchor rather than dismiss itself permanently.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
WalkthroughThe change replaces raw anchor bounds with structured geometry and visibility state. Popup positioning uses uncropped anchor geometry. Visible balloons dismiss when anchors become clipped or leave the window. Tests and documentation cover these cases. ChangesBalloon anchor capture and popup behavior
Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant AnchorModifier
participant BalloonHost
participant BalloonPopupLayer
participant PositionProvider
AnchorModifier->>BalloonHost: Capture BalloonAnchor
BalloonHost->>BalloonPopupLayer: Pass structured anchor
BalloonPopupLayer->>PositionProvider: Use anchor.rect
BalloonPopupLayer->>BalloonPopupLayer: Track visibility and dismiss when needed
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit reads each line, Comment |
Fixes #1022. The anchor bounds were captured with
boundsInWindow(), which clips — an anchor scrolled out of aModifier.verticalScrollcolumn collapses toRect.Zero, so the balloon was placed against the window origin (the arrow jumping to the top-left corner), and the off-screen dismissal never fired because it skipped empty rects.The anchor rect now comes from
localToWindowon its four corners, and the clipped rect is used only to decide whether the anchor is still on screen — which also covers an anchor clipped away inside the window, something the old window-coordinate check could not see.Covered by four regression tests in
ReportedScenarioTest, each confirmed to fail against the current code.Summary by CodeRabbit
Bug Fixes
Documentation