Skip to content

Fix/jaco/fix right click menu bug#107

Open
Jaaco wants to merge 2 commits into
mainfrom
fix/jaco/fix-right-click-menu-bug
Open

Fix/jaco/fix right click menu bug#107
Jaaco wants to merge 2 commits into
mainfrom
fix/jaco/fix-right-click-menu-bug

Conversation

@Jaaco

@Jaaco Jaaco commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes the bug where sometimes right-click menus would be impossible to dismiss, causing the app to break until restart.

I believe the issue was that both the menu handler AND the item wrapper would add an overlay in the corresponding gesture detectors, and the overlay state in the handler would end up to be null but not removed.

My changes don't wrap the whole app in a right click menu - which didn't do anything anyways, and instead relies on the specific wrapped items (the only place where it is actionable. Fixes the bug and improves UX.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Tests

Summary by CodeRabbit

  • Features

    • Right-click behavior is now individually configurable for UI items.
    • The add-image button no longer responds to right-click actions.
  • Improvements

    • Refined right-click context menu handling with improved cleanup during widget disposal.

@Jaaco
Jaaco requested a review from BenAuerDev February 26, 2026 11:20
@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces granular control over right-click behavior by adding an enableRightClick parameter to PanelListItem that propagates through to RightClickableItemWrapper as isEnabled. It refactors RightClickMenuHandler to remove its build-path right-click gesture detection while preserving internal logic. Usage in main_frame_list.dart disables right-click for the add-image item.

Changes

Cohort / File(s) Summary
Right-Click Configuration
apps/flites/lib/ui/panel/controls/panel_list_item.dart, apps/flites/lib/widgets/right_click_menu/right_clickable_item_wrapper.dart
Added enableRightClick/isEnabled boolean parameters (default true) to allow runtime toggling of right-click behavior. Conditional logic wraps the secondary tap handler to suppress it when disabled.
Right-Click Menu Handler Refactoring
apps/flites/lib/widgets/right_click_menu/right_click_menu_handler.dart
Removed GestureDetector and onSecondaryTapDown from build path while preserving internal showContextMenu logic. Added disposal hook to clean up overlay on widget destruction.
Configuration Usage
apps/flites/lib/widgets/project_file_list/widgets/main_frame_list.dart
Applied enableRightClick: false to the trailing add-image PanelListItem to disable right-click for that specific item.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Needs Attention

Poem

🐰 A click to the right, now with power to control,
Disabling where needed, granting choice in full,
Through wrapper and handler, the flags make their way,
Fine-grained right-click magic—hooray, hooray! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix/jaco/fix right click menu bug' accurately describes the main change: fixing a right-click menu bug that caused the app to become unusable. It directly aligns with the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/jaco/fix-right-click-menu-bug

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/flites/lib/ui/panel/controls/panel_list_item.dart (1)

46-67: ⚠️ Potential issue | 🟡 Minor

copyWith is missing the enableRightClick parameter.

The new enableRightClick field is not included in the copyWith method. If copyWith is called on a PanelListItem with enableRightClick: false, the returned copy will revert to true (the default), potentially re-enabling right-click unintentionally.

🔧 Proposed fix to include enableRightClick in copyWith
   PanelListItem copyWith({
     bool? hoverSelected,
     bool? isSelected,
     VoidCallback? onTap,
     List<IconBtn> Function({required bool isHovered, required bool isActive})?
     actionButtons,
     String? title,
     String? subtitle,
     FlitesImage? image,
     String? value,
     IconData? icon,
+    bool? enableRightClick,
   }) => PanelListItem(
     title: title ?? this.title,
     subtitle: subtitle ?? this.subtitle,
     image: image ?? this.image,
     actionButtons: actionButtons ?? this.actionButtons,
     isSelected: isSelected ?? this.isSelected,
     onTap: onTap ?? this.onTap,
     hoverSelected: hoverSelected ?? this.hoverSelected,
     value: value ?? this.value,
     icon: icon ?? this.icon,
+    enableRightClick: enableRightClick ?? this.enableRightClick,
   );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/flites/lib/ui/panel/controls/panel_list_item.dart` around lines 46 - 67,
The copyWith implementation for PanelListItem omits the enableRightClick field,
causing copies to revert to the default value; add a nullable parameter bool?
enableRightClick to the PanelListItem.copyWith signature and pass it through to
the PanelListItem constructor as enableRightClick: enableRightClick ??
this.enableRightClick so the original setting is preserved when not overridden.
🧹 Nitpick comments (1)
apps/flites/lib/widgets/right_click_menu/right_click_menu_handler.dart (1)

10-16: Stale documentation: comments no longer match behavior.

The doc comment describes this widget as listening for right-click events and showing a context menu, but after this change, build() simply returns the child and no longer intercepts right-clicks. Consider updating the documentation to reflect that this widget now serves as an ancestor state holder for RightClickableItemWrapper to access via findAncestorStateOfType.

Also applies to: 152-152

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/flites/lib/widgets/right_click_menu/right_click_menu_handler.dart`
around lines 10 - 16, Update the stale doc comment on the RightClickMenuHandler
class and its build() method to reflect current behavior: it no longer
intercepts right-clicks or shows context menus but instead acts as an ancestor
StatefulWidget/state holder that RightClickableItemWrapper obtains via
findAncestorStateOfType to coordinate context-menu actions; also update any
duplicate comment associated with RightClickMenuHandler (the second doc block)
to the same description so docs match the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/flites/lib/ui/panel/controls/panel_list_item.dart`:
- Around line 46-67: The copyWith implementation for PanelListItem omits the
enableRightClick field, causing copies to revert to the default value; add a
nullable parameter bool? enableRightClick to the PanelListItem.copyWith
signature and pass it through to the PanelListItem constructor as
enableRightClick: enableRightClick ?? this.enableRightClick so the original
setting is preserved when not overridden.

---

Nitpick comments:
In `@apps/flites/lib/widgets/right_click_menu/right_click_menu_handler.dart`:
- Around line 10-16: Update the stale doc comment on the RightClickMenuHandler
class and its build() method to reflect current behavior: it no longer
intercepts right-clicks or shows context menus but instead acts as an ancestor
StatefulWidget/state holder that RightClickableItemWrapper obtains via
findAncestorStateOfType to coordinate context-menu actions; also update any
duplicate comment associated with RightClickMenuHandler (the second doc block)
to the same description so docs match the implementation.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 351fbb4 and 7434bef.

📒 Files selected for processing (4)
  • apps/flites/lib/ui/panel/controls/panel_list_item.dart
  • apps/flites/lib/widgets/project_file_list/widgets/main_frame_list.dart
  • apps/flites/lib/widgets/right_click_menu/right_click_menu_handler.dart
  • apps/flites/lib/widgets/right_click_menu/right_clickable_item_wrapper.dart

@BenAuerDev BenAuerDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, please check if the enableRightClick should be passed to copyWith and maybe update the doc comment

Comment on lines +57 to +67
}) => PanelListItem(
title: title ?? this.title,
subtitle: subtitle ?? this.subtitle,
image: image ?? this.image,
actionButtons: actionButtons ?? this.actionButtons,
isSelected: isSelected ?? this.isSelected,
onTap: onTap ?? this.onTap,
hoverSelected: hoverSelected ?? this.hoverSelected,
value: value ?? this.value,
icon: icon ?? this.icon,
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should enableRightClick be included in the copyWIth?

Suggested change
}) => PanelListItem(
title: title ?? this.title,
subtitle: subtitle ?? this.subtitle,
image: image ?? this.image,
actionButtons: actionButtons ?? this.actionButtons,
isSelected: isSelected ?? this.isSelected,
onTap: onTap ?? this.onTap,
hoverSelected: hoverSelected ?? this.hoverSelected,
value: value ?? this.value,
icon: icon ?? this.icon,
);
}) => PanelListItem(
title: title ?? this.title,
subtitle: subtitle ?? this.subtitle,
image: image ?? this.image,
actionButtons: actionButtons ?? this.actionButtons,
isSelected: isSelected ?? this.isSelected,
onTap: onTap ?? this.onTap,
hoverSelected: hoverSelected ?? this.hoverSelected,
value: value ?? this.value,
icon: icon ?? this.icon,
enableRightClick: enableRightClick ?? this.enableRightClick,
);


/// A widget that wraps around the whole application to handle
/// right-click context menus.
/// It listens for right-click events and shows a context menu with the following options:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This line in the doc needs to be updated, since now only wrapped items listen for right-click events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants