From 566b1679e24a6cb314bf1d9824357e36151d8441 Mon Sep 17 00:00:00 2001 From: WXL-steven <76638078+WXL-steven@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:37:36 +0800 Subject: [PATCH 1/2] Fix: Disabled `PaneItem` Still Accessible in Compact Mode of `NavigationPane` **Description:** This Pull Request addresses the issue where `PaneItem` widgets with `enabled: false` are still accessible when the `NavigationPane` is in `PaneDisplayMode.compact` mode. **Changes Made:** - Modified `pane_items.dart` to ensure that `onPressed` and `forceEnabled` values are correctly passed based on the `item.enabled` property. - Updated the `builder` to merge the theme of the icon and title based on the `states`. **Issue Reference:** This PR resolves the bug where disabled `PaneItem` widgets can be navigated to when the `NavigationPane` is in compact mode, as described in the related issue: https://github.com/bdlukaa/fluent_ui/issues/1081 --- .../navigation_view/pane_items.dart | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/src/controls/navigation/navigation_view/pane_items.dart b/lib/src/controls/navigation/navigation_view/pane_items.dart index ce754c4b0..7adb3472f 100644 --- a/lib/src/controls/navigation/navigation_view/pane_items.dart +++ b/lib/src/controls/navigation/navigation_view/pane_items.dart @@ -927,13 +927,26 @@ class _PaneItemExpanderMenuItem extends MenuFlyoutItemBase { Widget build(BuildContext context) { assert(debugCheckHasFluentTheme(context)); final theme = FluentTheme.of(context); + final navigationTheme = NavigationPaneTheme.of(context); final size = Flyout.of(context).size; return Container( width: size.isEmpty ? null : size.width, padding: MenuFlyout.itemsPadding, child: HoverButton( - onPressed: onPressed, + onPressed: item.enabled ? onPressed : null, + forceEnabled: item.enabled, builder: (context, states) { + final textStyle = (isSelected + ? navigationTheme.selectedTextStyle?.resolve(states) + : navigationTheme.unselectedTextStyle?.resolve(states)) + ?? const TextStyle(); + final iconTheme = IconThemeData( + color: textStyle.color ?? + (isSelected + ? navigationTheme.selectedIconColor?.resolve(states) + : navigationTheme.unselectedIconColor?.resolve(states)), + size: textStyle.fontSize ?? 16.0, + ); return Container( padding: const EdgeInsets.symmetric( horizontal: 10.0, @@ -951,11 +964,17 @@ class _PaneItemExpanderMenuItem extends MenuFlyoutItemBase { child: Row(mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsetsDirectional.only(end: 12.0), - child: item.icon, + child: IconTheme.merge( + data: iconTheme, + child: item.icon, + ), ), Flexible( fit: size.isEmpty ? FlexFit.loose : FlexFit.tight, - child: item.title ?? const SizedBox.shrink(), + child: DefaultTextStyle( + style: textStyle, + child: item.title ?? const SizedBox.shrink(), + ), ), if (item.infoBadge != null) Padding( From 7ec07b3f0e3e2e6d960c7e562a160cef3e0e4abd Mon Sep 17 00:00:00 2001 From: WXL-steven <76638078+WXL-steven@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:51:33 +0800 Subject: [PATCH 2/2] updated CHANGELOG.md & run 'dart format .' --- CHANGELOG.md | 3 +++ lib/src/controls/navigation/navigation_view/pane_items.dart | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36c787c0f..434ce4ecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## NEXT +* fix: Resolved issue where `PaneItem` within `PaneItemExpander` remained accessible in `NavigationPane` compact mode ([#1081](https://github.com/bdlukaa/fluent_ui/issues/1081)) + ## 4.9.0 * fix: ¹ `DropDownButton.closeAfterClick` is now correctly applied. ² Added `MenuFlyoutItem.closeAfterClick`, which defaults to `true`. ([#1016](https://github.com/bdlukaa/fluent_ui/issues/1016)) diff --git a/lib/src/controls/navigation/navigation_view/pane_items.dart b/lib/src/controls/navigation/navigation_view/pane_items.dart index 7adb3472f..b8fea2afe 100644 --- a/lib/src/controls/navigation/navigation_view/pane_items.dart +++ b/lib/src/controls/navigation/navigation_view/pane_items.dart @@ -937,9 +937,9 @@ class _PaneItemExpanderMenuItem extends MenuFlyoutItemBase { forceEnabled: item.enabled, builder: (context, states) { final textStyle = (isSelected - ? navigationTheme.selectedTextStyle?.resolve(states) - : navigationTheme.unselectedTextStyle?.resolve(states)) - ?? const TextStyle(); + ? navigationTheme.selectedTextStyle?.resolve(states) + : navigationTheme.unselectedTextStyle?.resolve(states)) ?? + const TextStyle(); final iconTheme = IconThemeData( color: textStyle.color ?? (isSelected