Skip to content

fix(gesture): only start gestures on the primary mouse button - #31561

Open
Metehan-Bicer wants to merge 1 commit into
ionic-team:mainfrom
Metehan-Bicer:fix/gesture-primary-button
Open

Metehan-Bicer wants to merge 1 commit into
ionic-team:mainfrom
Metehan-Bicer:fix/gesture-primary-button

Conversation

@Metehan-Bicer

Copy link
Copy Markdown

Issue number: resolves #29872


What is the current behavior?

The pointer-events gesture helper starts a gesture on mousedown for any mouse button. On macOS a right click opens the context menu, which swallows the mouseup, so the gesture stays active: moving the pointer keeps dragging the ion-segment indicator, changes the value and fires ionChange until the next left click. ion-range, ion-toggle and the other drag-based components share the helper.

What is the new behavior?

  • handleMouseDown in core/src/utils/gesture/pointer-events.ts returns early for a non-primary button (ev.button > 0), so right and middle clicks no longer start a gesture. The tap-click utility already ignores right clicks the same way. Touch input is unchanged, and an event without a button value still starts the gesture as before.
  • New e2e test in segment-events.e2e.ts: holding the right button on the selected segment button and moving to the last one leaves the value at 1 and emits no ionChange. Playwright can't open the native context menu, so the test keeps the right button pressed while the pointer moves, which hits the same code path. It fails on main in Chromium, Firefox and WebKit (Expected: "1" Received: "3") and passes with the change. The left-button drag is still covered by the existing test.

I checked the other createGesture users (range, toggle, menu, item-sliding, reorder, refresher, modal sheet, toast, swipe back): none relies on a non-primary button.

Does this introduce a breaking change?

  • Yes
  • No

Other information

segment-events.e2e.ts passes (27 tests), and so do the spec suite and the non-screenshot range and toggle e2e tests (range-events, custom, scroll, scroll-target, dual-knobs, toggle a11y). Ctrl+click on macOS also opens the context menu but reports button === 0, so it isn't covered here.

A right click started the drag gesture of segment, range, toggle and the
other gesture-based components. On macOS the context menu swallows the
mouseup, so the gesture stayed active and moving the pointer changed the
value until the next left click.

resolves ionic-team#29872
@Metehan-Bicer
Metehan-Bicer requested a review from a team as a code owner October 10, 2026 22:23
@github-actions github-actions Bot added the package: core @ionic/core package label Oct 10, 2026
@vercel

vercel Bot commented Oct 10, 2026

Copy link
Copy Markdown

@Metehan-Bicer is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-segment-buttons activating improperly after opening contextmenu (right mouse click) on Mac

1 participant