Skip to content

fix: NavigationView compact pane PaneItemExpander flyout size and position#1310

Merged
bdlukaa merged 4 commits intomasterfrom
copilot/fix-navigationview-compact-pane-size
Mar 17, 2026
Merged

fix: NavigationView compact pane PaneItemExpander flyout size and position#1310
bdlukaa merged 4 commits intomasterfrom
copilot/fix-navigationview-compact-pane-size

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

In RTL directionality, the compact navigation pane appears on the physical right side of the screen. The flyout was hardcoded to FlyoutPlacementMode.rightTop, which only had ~50px of available space (the pane width itself) rather than the full content area width. Additionally, the leftTop/rightTop flyout placement modes had a vertical positioning bug that caused flyouts to appear in the middle of the screen instead of aligned with the target item.

Changes

  • pane_items.dart: Resolve the flyout placement mode against the current text direction so it uses leftTop in RTL (physically left = into the content area) and rightTop in LTR — leveraging the existing FlyoutPlacementMode.resolve() method.
// Before
placementMode: displayMode == PaneDisplayMode.compact
    ? FlyoutPlacementMode.rightTop
    : FlyoutPlacementMode.bottomCenter,

// After
final textDirection = Directionality.of(context);
placementMode: displayMode == PaneDisplayMode.compact
    ? FlyoutPlacementMode.rightTop.resolve(textDirection)
    : FlyoutPlacementMode.bottomCenter,
  • flyout.dart: Fixed horizontalTopY calculation in _FlyoutPositionDelegate. The old formula used two chained clampVertical calls that produced incorrect results when the flyout is taller than the space above the target element, causing the flyout to appear in the middle of the screen:
// Before - wrong when flyout height exceeds space above target:
final topY = clampVertical(targetOffset.dy - targetSize.height - flyoutSize.height);
final horizontalTopY = clampVertical(topY + flyoutSize.height);

// After - directly computes the top edge of the target element:
final horizontalTopY = clampVertical(targetOffset.dy - targetSize.height);
  • test/navigation_view_test.dart: Added regression test asserting the flyout width exceeds kCompactNavigationPaneWidth when opened in RTL compact mode.
  • CHANGELOG.md: Added entries under 4.15.0.
Original prompt

This section details on the original issue you should resolve

<issue_title>🐛 NavigationView compact pane Flyout is too small when in right-to-left directionality</issue_title>
<issue_description>To Reproduce
Steps to reproduce the behavior:

  1. Set directionality to right-to-left
  2. Set navigation view pane to compact mode
  3. Add a PaneItemExpander and children
  4. Press pane item expander on the sidebar.

Expected behavior
Same as left-to-right.

Screenshots
Image

Additional context
n/a
</issue_description>

<agent_instructions>Update the tests and update the changelog at the end.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: bdlukaa <45696119+bdlukaa@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix NavigationView compact pane Flyout size in right-to-left directionality fix: NavigationView compact pane PaneItemExpander flyout too small in RTL Mar 17, 2026
Copilot AI requested a review from bdlukaa March 17, 2026 01:10
@bdlukaa
Copy link
Owner

bdlukaa commented Mar 17, 2026

@copilot The first PaneItemExpander of the home screen is being displayed at the middle of the screen. It should be positioned correctly.

…s tall

Co-authored-by: bdlukaa <45696119+bdlukaa@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 17, 2026

@copilot The first PaneItemExpander of the home screen is being displayed at the middle of the screen. It should be positioned correctly.

Fixed in d2a9f35. The root cause was a bug in _FlyoutPositionDelegate.getPositionForChild in flyout.dart. The horizontalTopY variable (used for leftTop/rightTop placement) was computed via two chained clampVertical calls:

// Old - wrong when flyout is taller than space above the target:
final topY = clampVertical(targetOffset.dy - targetSize.height - flyoutSize.height);
final horizontalTopY = clampVertical(topY + flyoutSize.height);

When topY gets clamped to margin (item near the top, tall flyout), horizontalTopY becomes margin + flyoutSize.height — placing the flyout far too low.

// New - directly computes the top edge of the target:
final horizontalTopY = clampVertical(targetOffset.dy - targetSize.height);

This correctly aligns the flyout's top edge with the top of the target element in all cases.

Copilot AI changed the title fix: NavigationView compact pane PaneItemExpander flyout too small in RTL fix: NavigationView compact pane PaneItemExpander flyout size and position Mar 17, 2026
@bdlukaa bdlukaa marked this pull request as ready for review March 17, 2026 01:33
@bdlukaa bdlukaa merged commit 6bc5bb6 into master Mar 17, 2026
1 of 3 checks passed
@bdlukaa bdlukaa deleted the copilot/fix-navigationview-compact-pane-size branch March 17, 2026 01:43
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.

🐛 NavigationView compact pane Flyout is too small when in right-to-left directionality

2 participants