Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ISSUE: MenuFlyoutSubItem was not displaying when hovered or pressing over in a DropdownButton. #964

Merged
merged 6 commits into from
Nov 30, 2023

Conversation

Abbas1Hussein
Copy link
Contributor

@Abbas1Hussein Abbas1Hussein commented Nov 14, 2023

The error occurred because of the inheritance relationship between the MenuFlyoutSubItem class that extends from MenuFlyoutItem.

before ( picture )1:

if (widget.closeAfterClick && item is MenuFlyoutItem);

after ( picture 2):

if (item is MenuFlyoutSubItem) {
 return _buildMenuFlyoutISubItem(item);
}

if (widget.closeAfterClick && item is MenuFlyoutItem) {
 return _buildMenuFlyoutItem(item, context);
}
Issue After Fixed

Checklist

  • I have updated CHANGELOG.md with my changes
  • I have run "dart format ." on the project

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 16, 2023

Could you explain the issue better? I don't understand it

@Abbas1Hussein
Copy link
Contributor Author

Could you explain the issue better? I don't understand it

The Problem:
the MenuFlyoutSubItem is not displaying when hovered or pressed.

return DropDownButton(
  title: const Text('menu'),
  items: [
    MenuFlyoutItem(
      text: const Text('import'),
      onPressed: () {},
    ),
    // MenuFlyoutSubItem items will not display when hovered or pressed.
    MenuFlyoutSubItem(
      text: const Text('open with...'),
      items: (context) {
        return [
          MenuFlyoutItem(text: const Text('powerpoint'), onPressed: () {}),
          MenuFlyoutItem(text: const Text('excel'), onPressed: () {}),
          MenuFlyoutItem(text: const Text('word'), onPressed: () {}),
        ];
      },
    ),
    MenuFlyoutItem(text: const Text('export'), onPressed: () {}),
  ],
);

Upon further reflection, I've identified an issue with the initial solution proposed in the pull request.

and best solution it removing the closeAfterClick parmater,
and closeing MenuFlyoutItem automatically after a click.

Revised Solution:

  • Remove closeAfterClick and automatically close MenuFlyoutItem after a click.

I acknowledge that the initial solution might not have been entirely accurate, and I believe this revised approach provides a more effective resolution.

I'm open to any feedback you may have and am willing to make further adjustments if necessary.

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 19, 2023

I like the first solution better. I'd like to keep the closeAfterClick property, since this is the case on the native side.

@Abbas1Hussein
Copy link
Contributor Author

I like the first solution better. I'd like to keep the closeAfterClick property, since this is the case on the native side.

the issue is related to the fact that only the first MenuFlyoutSubItem is displayed as expected, but subsequent ones are not showing correctly when hovered or pressed.

return DropDownButton(
  title: const Text('menu'),
  items: [
    MenuFlyoutItem(
      text: const Text('import'),
      onPressed: () {},
    ),
    // MenuFlyoutSubItem items will display when hovered or pressed.
    MenuFlyoutSubItem(
      text: const Text('open with...'),
      items: (context) {
        return [
          MenuFlyoutItem(text: const Text('powerpoint'), onPressed: () {}),
          MenuFlyoutItem(text: const Text('excel'), onPressed: () {}),
          MenuFlyoutItem(text: const Text('word'), onPressed: () {}),
        ];
      },
    ),
    // Additional MenuFlyoutSubItem items will not display when hovered or pressed.
    MenuFlyoutSubItem(
      text: const Text('open with 2 ...'),
      items: (context) {
        return [
          MenuFlyoutItem(text: const Text('powerpoint 2'), onPressed: () {}),
          MenuFlyoutItem(text: const Text('excel 2'), onPressed: () {}),
          MenuFlyoutItem(text: const Text('word 2'), onPressed: () {}),
        ];
      },
    ),
    MenuFlyoutItem(text: const Text('export'), onPressed: () {}),
  ],
);

I will make another attempt to resolve the issue while retaining the closeAfterClick property.

@Abbas1Hussein
Copy link
Contributor Author

Hello there, I've resolved all the issues, and now it works as expected.

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 27, 2023

Hello, the tests are not passing and you should rebase your branch.

@Abbas1Hussein
Copy link
Contributor Author

Hello, the tests are not passing and you should rebase your branch.

  • dart format lib/src/controls/inputs/dropdown_button.dart
    Formatted 1 file (0 changed) in 0.40 seconds.

  • dart analyze
    Analyzing fluent_ui... No issues found!

@bdlukaa bdlukaa merged commit 31b0fe0 into bdlukaa:master Nov 30, 2023
2 of 3 checks passed
@Abbas1Hussein Abbas1Hussein deleted the fix_dropdown branch January 28, 2024 19:18
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.

2 participants