Skip to content

Menu: Stay open after being clicked with MouseOver#9513

Merged
henon merged 18 commits intoMudBlazor:devfrom
danielchalmers:menu-mouseover-touch
Aug 3, 2024
Merged

Menu: Stay open after being clicked with MouseOver#9513
henon merged 18 commits intoMudBlazor:devfrom
danielchalmers:menu-mouseover-touch

Conversation

@danielchalmers
Copy link
Member

@danielchalmers danielchalmers commented Jul 26, 2024

Description

Closes #9470 by refactoring some of the menu code and allowing you to click the activator to keep the menu open while using MouseOver. This is relevant on touch devices where you can't hover, so the menu would only stay open as long as you held a tap.

Tried to avoid any breaking changes.

How Has This Been Tested?

unit, visually

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Clicking the button will toggle the overlay, allowing you to hide the menu. If it's already closed (like if touched) then it will stay open until you click the overlay.

Touch:

video3.mp4

Mouse:

video4.mp4

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

Closes MudBlazor#9470

Potential future improvements:
- Expand MouseEvent and make it a flag enum?
- Context menu will always be prevented for long touches
@github-actions github-actions bot added the bug Unexpected behavior or functionality not working as intended label Jul 26, 2024
@danielchalmers danielchalmers changed the title Menu: Toggle on click with MouseOver Menu: Stay open after being clicked with MouseOver Jul 27, 2024
@danielchalmers danielchalmers marked this pull request as ready for review July 27, 2024 18:06
@codecov
Copy link

codecov bot commented Jul 27, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.52%. Comparing base (28bc599) to head (bdf7ecc).
Report is 392 commits behind head on dev.

Files Patch % Lines
src/MudBlazor/Components/Menu/MudMenu.razor.cs 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9513      +/-   ##
==========================================
+ Coverage   89.82%   90.52%   +0.69%     
==========================================
  Files         412      407       -5     
  Lines       11878    12741     +863     
  Branches     2364     2474     +110     
==========================================
+ Hits        10670    11534     +864     
+ Misses        681      643      -38     
- Partials      527      564      +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +334 to +335
// Wait a bit to allow the cursor to move from the activator to the items popover.
await Task.Delay(100);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably make this timespan configurable via globals, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

But seeing as it has already been that way, this can be done later or maybe it isn't needed at all.

Copy link
Member Author

@danielchalmers danielchalmers Aug 3, 2024

Choose a reason for hiding this comment

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

It's a little awkward because if you set it too low you won't be able to move the cursor to the menu. I've been trying to think of a way to remove it altogether and avoid any timing issues

Copy link
Member Author

@danielchalmers danielchalmers Aug 3, 2024

Choose a reason for hiding this comment

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

It's needed because the menu is separated from the activator, but maybe we extend the hit bounds while keeping that part visually transparent

Will investigate further in the future

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

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The MudMenu popover does not stay open after touching on touch devices when using MouseOver in ActivationEvent

3 participants