Skip to content

feat(ContextMenu): context menu should be invisible while scrolling#7822

Merged
ArgoZhang merged 11 commits intomainfrom
feat7821-context-menu-should-be-invisible-while-scrolling
Mar 31, 2026
Merged

feat(ContextMenu): context menu should be invisible while scrolling#7822
ArgoZhang merged 11 commits intomainfrom
feat7821-context-menu-should-be-invisible-while-scrolling

Conversation

@peereflits
Copy link
Copy Markdown
Collaborator

@peereflits peereflits commented Mar 30, 2026

This is a proposed solution, based on logical deduction.
It is hard for me to test this.

Link issues

fixes #7821

Summary By Copilot

Regression?

  • Yes
  • No (probably not)

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Ensure the context menu can be configured to hide while the user is scrolling on touch devices.

New Features:

  • Add an IsInvisibleOnTouchMove parameter to control whether the context menu is hidden during touch move events.

Bug Fixes:

  • Prevent the context menu from remaining visible while the user scrolls via touch by cancelling an in-progress touch-triggered invocation.

Enhancements:

  • Wire touch move handling into the context menu trigger rendering to support the new scrolling behavior.

This is a prposed solution, based on logical deduction.
It is hard for me to test this.
Copilot AI review requested due to automatic review settings March 30, 2026 17:36
@bb-auto
Copy link
Copy Markdown

bb-auto bot commented Mar 30, 2026

Thanks for your PR, @peereflits. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@bb-auto bb-auto bot added the enhancement New feature or request label Mar 30, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 30, 2026

Reviewer's Guide

Adds an optional behavior to hide the context menu while a touch scroll is in progress and wires a new touchmove handler into the ContextMenuTrigger rendering logic, including refactoring of RenderTree sequence numbers.

Sequence diagram for context menu touch scroll invisibility

sequenceDiagram
    actor User
    participant BrowserDom
    participant ContextMenuTrigger

    User->>BrowserDom: touchstart
    BrowserDom->>ContextMenuTrigger: OnTouchStart(TouchEventArgs)
    activate ContextMenuTrigger
    ContextMenuTrigger-->>ContextMenuTrigger: IsTouchStarted = true
    ContextMenuTrigger-->>ContextMenuTrigger: IsBusy = true
    deactivate ContextMenuTrigger

    User->>BrowserDom: touchmove (scroll)
    BrowserDom->>ContextMenuTrigger: OnTouchMove()
    activate ContextMenuTrigger
    alt IsInvisibleOnTouchMove == true
        ContextMenuTrigger-->>ContextMenuTrigger: IsBusy = false
        ContextMenuTrigger-->>ContextMenuTrigger: IsTouchStarted = false
        ContextMenuTrigger-->>BrowserDom: hide context menu
    else IsInvisibleOnTouchMove == false
        ContextMenuTrigger-->>BrowserDom: no visibility change
    end
    deactivate ContextMenuTrigger

    User->>BrowserDom: touchend
    BrowserDom->>ContextMenuTrigger: OnTouchEnd()
    activate ContextMenuTrigger
    ContextMenuTrigger-->>ContextMenuTrigger: IsTouchStarted = false
    deactivate ContextMenuTrigger
Loading

Class diagram for updated ContextMenuTrigger touch handling

classDiagram
    class ContextMenuTrigger {
        +bool IsInvisibleOnTouchMove
        -bool IsBusy
        -bool IsTouchStarted
        +void BuildRenderTree(RenderTreeBuilder builder)
        -Task OnTouchStart(TouchEventArgs e)
        -void OnTouchMove()
        -void OnTouchEnd()
        -Task OnContextMenu(MouseEventArgs e)
    }

    class RenderTreeBuilder
    class TouchEventArgs
    class MouseEventArgs

    ContextMenuTrigger ..> RenderTreeBuilder : builds
    ContextMenuTrigger ..> TouchEventArgs : handles
    ContextMenuTrigger ..> MouseEventArgs : handles
Loading

File-Level Changes

Change Details Files
Introduce an IsInvisibleOnTouchMove parameter to control hiding the context menu when a touch move occurs.
  • Add a new boolean component parameter with XML docs in both Chinese and English describing the behavior and default value
  • Expose the parameter on ContextMenuTrigger so consumers can opt in to hiding the menu during scroll
src/BootstrapBlazor/Components/ContextMenu/ContextMenuTrigger.cs
Wire touchmove handling into the render tree and reset touch state when scrolling to hide the menu.
  • Refactor BuildRenderTree to use an incrementing index variable instead of hard-coded sequence numbers and add an ontouchmove attribute bound to a new OnTouchMove handler
  • Implement OnTouchMove to clear IsBusy and IsTouchStarted when IsInvisibleOnTouchMove is true, effectively cancelling the long-press context menu during scrolling
  • Ensure ontouchstart and ontouchend remain wired so the existing touch behavior is preserved
src/BootstrapBlazor/Components/ContextMenu/ContextMenuTrigger.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7821 Add a configurable parameter on ContextMenuTrigger (e.g., IsInvisibleOnTouchMove, default false) to control whether the context menu should be invisible while scrolling on touch devices.
#7821 Update touch handling so that when the user moves their finger (scrolls) while touching and the new parameter is enabled, the pending/visible context menu is canceled or hidden, without changing existing mouse (right-click) behavior.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a46488a) to head (53637c6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7822   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          764       764           
  Lines        34131     34142   +11     
  Branches      4699      4701    +2     
=========================================
+ Hits         34131     34142   +11     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The OnTouchMove handler is registered as EventCallback.Factory.Create<TouchEventArgs>(this, OnTouchMove) but the method signature private void OnTouchMove() does not accept a TouchEventArgs parameter, which will cause a mismatch; either add a TouchEventArgs parameter or adjust the EventCallback creation.
  • When cancelling a touch invocation on OnTouchMove by setting IsBusy = false and IsTouchStarted = false, consider also cancelling any pending delay logic associated with OnTouchDelay (if present elsewhere) to avoid a delayed menu opening after a scroll.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `OnTouchMove` handler is registered as `EventCallback.Factory.Create<TouchEventArgs>(this, OnTouchMove)` but the method signature `private void OnTouchMove()` does not accept a `TouchEventArgs` parameter, which will cause a mismatch; either add a `TouchEventArgs` parameter or adjust the `EventCallback` creation.
- When cancelling a touch invocation on `OnTouchMove` by setting `IsBusy = false` and `IsTouchStarted = false`, consider also cancelling any pending delay logic associated with `OnTouchDelay` (if present elsewhere) to avoid a delayed menu opening after a scroll.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts ContextMenuTrigger touch handling so a long-press context menu can be suppressed when the user starts scrolling (touch-move), addressing #7821 for touch devices (e.g., MAUI).

Changes:

  • Added IsInvisibleOnTouchMove [Parameter] to opt into canceling the long-press menu when a touch-move occurs.
  • Wired up an ontouchmove handler to reset internal touch state during scrolling.
  • Refactored BuildRenderTree sequence numbers to use an incrementing index to accommodate the new attribute.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ArgoZhang ArgoZhang changed the title Fix: context menu should be invisible while scrolling #7821 feat(ContextMenu): context menu should be invisible while scrolling Mar 31, 2026
@ArgoZhang ArgoZhang merged commit b587197 into main Mar 31, 2026
6 checks passed
@ArgoZhang ArgoZhang deleted the feat7821-context-menu-should-be-invisible-while-scrolling branch March 31, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ContextMenu): context menu should be invisible while scrolling

3 participants