Skip to content

Fix popover/card/dialog/alert/toast/tile/item content overflowing rounded border#1013

Merged
Pante merged 3 commits into
mainfrom
fix/clipping
May 11, 2026
Merged

Fix popover/card/dialog/alert/toast/tile/item content overflowing rounded border#1013
Pante merged 3 commits into
mainfrom
fix/clipping

Conversation

@Pante

@Pante Pante commented May 11, 2026

Copy link
Copy Markdown
Member

Describe the changes

Fixes #990.

  • Add a reusable InnerPathClipper foundation utility that clips to the inner path of a Decoration (handling ShapeDecoration, BoxDecoration + border + borderRadius via ShapeDecoration.fromBoxDecoration, with a getClipPath fallback).
  • Add opt-in clipBehavior parameter (default Clip.none) to FCard, FDialog, FAlert, FToast, plus popoverClipBehavior on FPopover. When set, content is wrapped in ClipPath(InnerPathClipper(...)) so children can't overflow the rounded corners or paint over the border ring.
  • Refactor FTileGroup and FItemGroup to use DecoratedBox + ClipPath(InnerPathClipper) instead of Container + auto-padding + outer-path ShapeBorderClipper/ClipRRect. Drops the // ignore: use_decorated_box workaround and the misleading "border would be clipped" comment. Strictly better at curved corners.
  • Switch FItem's focused outline from an inline position: .foreground BoxDecoration to FFocusedOutline so it isn't cropped by the group's new inner-path clip. The outline now respects focusedOutlineStyle.spacing (already set to -borderWidth on items / -borderWidth - 5 on tiles, drawing inset into the child's bounds).
  • Clamp FFocusedOutline.spacing at runtime so large negative values never produce a degenerate rect.

Checklist

  • I have read the CONTRIBUTING.md.
  • I have included the relevant unit/golden tests.
  • I have included the relevant samples.
  • I have updated the documentation accordingly.
  • I have added the required flutters_hook for widget controllers.
  • I have updated the CHANGELOG.md if necessary.

🤖 Generated with Claude Code

Fixes #990.

Add a reusable InnerPathClipper foundation utility and wire it into
FPopover, FCard, FDialog, FAlert, FToast (opt-in via clipBehavior /
popoverClipBehavior, default Clip.none) and FTileGroup, FItemGroup
(always-on, replacing the previous outer-path clip).

Switch FItem's focused outline from an inline foreground BoxDecoration
to FFocusedOutline so the new inner-path clip in FTileGroup/FItemGroup
no longer crops the outline. Clamp FFocusedOutline.spacing at runtime
so negative values don't produce a degenerate rect.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 11, 2026 14:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses content painting past rounded corners / over border rings across several Forui surfaces (popover, card, dialog, alert, toast, tile/item groups) by introducing a reusable “inner-path” clipper and wiring new opt-in clipping APIs into affected widgets.

Changes:

  • Added InnerPathClipper utility and used it to clip widget children to the inner decoration path (inside the border).
  • Introduced opt-in clipBehavior/popoverClipBehavior parameters for FAlert, FCard, FDialog, FToast, and FPopover, plus updated golden coverage for clipping behavior.
  • Refactored FTileGroup/FItemGroup clipping approach and adjusted focused-outline rendering to avoid being cropped (including runtime clamping for large negative spacing).

Reviewed changes

Copilot reviewed 19 out of 263 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
forui/lib/src/foundation/inner_path_clipper.dart New decoration-aware clipper intended to clip children to decoration inner paths.
forui/lib/src/foundation/focused_outline.dart Clamp negative spacing at paint time to avoid degenerate/inverted outline rects.
forui/lib/src/widgets/toast/toast.dart Add clipBehavior and clip toast content via InnerPathClipper when enabled.
forui/lib/src/widgets/alert.dart Add clipBehavior and clip alert content via InnerPathClipper when enabled.
forui/lib/src/widgets/card/card.dart Add clipBehavior and clip card content via InnerPathClipper when enabled.
forui/lib/src/widgets/dialog/dialog.dart Add clipBehavior and clip dialog content via InnerPathClipper when enabled.
forui/lib/src/widgets/popover/popover.dart Add popoverClipBehavior and clip popover content via InnerPathClipper when enabled.
forui/lib/src/widgets/popover_menu/popover_menu.dart Enable popover clipping by default for popover menus (.antiAlias).
forui/lib/src/widgets/item/item.dart Route focused outline through FTappable (instead of foreground decoration) to avoid being clipped by group clipping.
forui/lib/src/widgets/item/item_group.dart Refactor group decoration/clipping to use DecoratedBox + ClipPath(InnerPathClipper).
forui/lib/src/widgets/tile/tile.dart Adjust focused-outline spacing for tiles to render inset appropriately.
forui/lib/src/widgets/tile/tile_group.dart Refactor group decoration/clipping to use DecoratedBox + ClipPath(InnerPathClipper).
forui/test/src/widgets/toast/toast_golden_test.dart Add golden coverage for toast clipping on/off; update imports for Colors.
forui/test/src/widgets/popover/popover_golden_test.dart Add golden coverage for popover clipping on/off.
forui/test/src/widgets/dialog/dialog_golden_test.dart Add golden coverage for dialog clipping on/off.
forui/test/src/widgets/card_golden_test.dart Add golden coverage for card clipping on/off.
forui/test/src/widgets/alert_golden_test.dart Add golden coverage for alert clipping on/off.
forui/test/src/foundation/focused_outline_test.dart Add regression tests ensuring large negative spacing does not crash painting.
forui/CHANGELOG.md Document new clipping parameters and group clipping fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread forui/lib/src/foundation/inner_path_clipper.dart
Comment thread forui/lib/src/widgets/popover/popover.dart Outdated
@Pante Pante merged commit 5b2d358 into main May 11, 2026
18 checks passed
@Pante Pante deleted the fix/clipping branch May 11, 2026 15:06
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.

Popovers could clip their content and maybe add 1px padding

2 participants