Skip to content

fix: use IsPrimary() for touch pointer isPrimary instead of hardcoded id#16099

Merged
acoates-ms merged 2 commits into
microsoft:mainfrom
Virtual-Fulfillment-Technologies-Inc:vendora/primary-touch-fix
May 11, 2026
Merged

fix: use IsPrimary() for touch pointer isPrimary instead of hardcoded id#16099
acoates-ms merged 2 commits into
microsoft:mainfrom
Virtual-Fulfillment-Technologies-Inc:vendora/primary-touch-fix

Conversation

@gmacmaster
Copy link
Copy Markdown
Contributor

@gmacmaster gmacmaster commented May 8, 2026

Description

activeTouch.isPrimary was set via pointerId == 1, which only works for
mouse (MOUSE_POINTER_ID == 1). Windows touch pointer IDs are OS-allocated
and essentially never 1, so isPrimary was always false for touch input.
This meant touch pointers never triggered onClick (gated behind
isPrimary && button == 0) and reported incorrect isPrimary in
PointerEvents sent to JS.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

Replace with pointerPoint.Properties().IsPrimary(), which reads the OS
POINTER_FLAG_PRIMARY flag directly. This API is already used elsewhere
in the codebase (SwitchComponentView, WindowsTextInputComponentView,
Composition.Input).

Resolves: N/a

What

Today, touch fingers never trigger onClick (because isPrimary is always false). After the fix, the primary finger would. Combined with secondary fix 1 above, those new clicks would be dispatched correctly per W3C — but they are still new dispatches that did not happen before. That is a behaviour change worth its own changeset, its own review, and its own test pass.

Changelog

Should this change be included in the release notes: yes

fix: use IsPrimary() for touch pointer isPrimary instead of hardcoded pointer ID check

Microsoft Reviewers: Open in CodeFlow

gmacmaster and others added 2 commits May 7, 2026 21:48
… ID check (#4)

activeTouch.isPrimary was set via `pointerId == 1`, which only works for
  mouse (MOUSE_POINTER_ID == 1). Windows touch pointer IDs are OS-allocated
  and essentially never 1, so isPrimary was always false for touch input.
  This meant touch pointers never triggered onClick (gated behind
  isPrimary && button == 0) and reported incorrect isPrimary in
  PointerEvents sent to JS.

  Replace with pointerPoint.Properties().IsPrimary(), which reads the OS
  POINTER_FLAG_PRIMARY flag directly. This API is already used elsewhere
  in the codebase (SwitchComponentView, WindowsTextInputComponentView,
  Composition.Input).

  (The diagnostics are pre-existing clang noise from missing PCH/Windows headers — not
  related to this change.)
@gmacmaster gmacmaster requested a review from a team as a code owner May 8, 2026 01:59
@acoates-ms
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@github-actions
Copy link
Copy Markdown

Performance Test Results

Branch: vendora/primary-touch-fix
Commit: 6f0177a3
Time: 2026-05-11T01:38:28.618Z
Tests: 161/161 passed

✅ Passed

161 scenario(s) across 28 suite(s) — no regressions

SectionList

Scenario Mean Median StdDev Renders vs Baseline
SectionList mount 5.20ms 4.50ms ±2.04ms 1 -10.0%
SectionList unmount 0.20ms 0.00ms ±0.42ms 0 +0.0%
SectionList rerender 11.80ms 11.00ms ±3.05ms 2 +4.8%
SectionList with-3-sections-15-items 6.20ms 5.50ms ±2.15ms 1 +0.0%
SectionList with-5-sections-50-items 6.10ms 6.00ms ±1.66ms 1 +0.0%
SectionList with-10-sections-200-items 6.00ms 5.00ms ±1.41ms 1 -9.1%
SectionList with-20-sections-200-items 5.00ms 4.50ms ±2.16ms 1 -10.0%
SectionList with-section-separator 2.30ms 2.00ms ±0.67ms 1 +0.0%
SectionList with-item-separator 2.00ms 2.00ms ±0.67ms 1 +0.0%
SectionList with-header-footer 2.40ms 3.00ms ±0.84ms 1 +50.0%
SectionList with-section-footer 2.40ms 2.00ms ±0.52ms 1 +0.0%
SectionList with-sticky-section-headers 1.80ms 2.00ms ±0.63ms 1 +0.0%
SectionList with-empty-list 0.60ms 1.00ms ±0.52ms 1 +0.0%
SectionList with-50-sections-1000-items 1.50ms 1.00ms ±0.71ms 1 -50.0%

FlatList

Scenario Mean Median StdDev Renders vs Baseline
FlatList mount 4.50ms 4.00ms ±1.65ms 1 +0.0%
FlatList unmount 0.20ms 0.00ms ±0.42ms 0 +0.0%
FlatList rerender 10.20ms 9.50ms ±1.93ms 2 +5.6%
FlatList with-10-items 6.50ms 5.00ms ±4.43ms 1 +25.0%
FlatList with-100-items 5.40ms 5.00ms ±1.84ms 1 +0.0%
FlatList with-500-items 6.00ms 6.00ms ±1.49ms 1 +50.0%
FlatList with-1000-items 5.10ms 4.00ms ±2.08ms 1 +0.0%
FlatList horizontal 3.70ms 4.00ms ±0.95ms 1 -20.0%
FlatList with-separator 2.10ms 2.00ms ±0.57ms 1 +0.0%
FlatList with-header-footer 1.40ms 1.00ms ±0.52ms 1 -50.0%
FlatList with-empty-list 0.40ms 0.00ms ±0.52ms 1 -100.0%
FlatList with-get-item-layout 1.60ms 2.00ms ±0.52ms 1 +100.0%
FlatList inverted 1.90ms 1.00ms ±2.18ms 1 -33.3%
FlatList with-num-columns 3.80ms 4.00ms ±0.92ms 1 +33.3%

TouchableOpacity

Scenario Mean Median StdDev Renders vs Baseline
TouchableOpacity mount 0.80ms 1.00ms ±0.63ms 1 +0.0%
TouchableOpacity unmount 0.10ms 0.00ms ±0.32ms 0 +0.0%
TouchableOpacity rerender 1.30ms 1.00ms ±0.67ms 2 +0.0%
TouchableOpacity custom-active-opacity 0.70ms 1.00ms ±0.48ms 1 +0.0%
TouchableOpacity disabled 0.60ms 1.00ms ±0.52ms 1 +0.0%
TouchableOpacity with-all-handlers 0.50ms 0.50ms ±0.53ms 1 -50.0%
TouchableOpacity with-hit-slop 0.80ms 1.00ms ±0.42ms 1 +0.0%
TouchableOpacity with-delay 0.60ms 1.00ms ±0.52ms 1 +0.0%
TouchableOpacity nested 1.20ms 1.00ms ±0.42ms 1 +0.0%
TouchableOpacity multiple-10 6.00ms 5.00ms ±2.36ms 1 -16.7%
TouchableOpacity multiple-50 26.33ms 26.00ms ±4.17ms 1 -10.3%
TouchableOpacity multiple-100 38.13ms 41.00ms ±12.65ms 1 -18.0%

ScrollView

Scenario Mean Median StdDev Renders vs Baseline
ScrollView mount 0.30ms 0.00ms ±0.48ms 1 +0.0%
ScrollView unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
ScrollView rerender 0.70ms 1.00ms ±0.48ms 2 +0.0%
ScrollView children-20 3.47ms 3.00ms ±1.73ms 1 -25.0%
ScrollView children-100 26.60ms 21.00ms ±17.22ms 1 +31.3%
ScrollView horizontal 4.90ms 4.00ms ±1.45ms 1 +0.0%
ScrollView sticky-headers 3.60ms 4.00ms ±1.35ms 1 +33.3%
ScrollView scroll-indicators 0.80ms 1.00ms ±0.42ms 1 +0.0%
ScrollView nested 1.40ms 1.00ms ±0.70ms 1 +0.0%
ScrollView content-container-style 0.90ms 1.00ms ±0.57ms 1 +0.0%
ScrollView children-500 35.53ms 26.00ms ±22.48ms 1 +36.8%

TouchableHighlight

Scenario Mean Median StdDev Renders vs Baseline
TouchableHighlight mount 0.30ms 0.00ms ±0.48ms 1 -100.0%
TouchableHighlight unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
TouchableHighlight rerender 0.60ms 1.00ms ±0.52ms 2 +0.0%
TouchableHighlight custom-underlay-color 0.60ms 1.00ms ±0.52ms 1 +Infinity%
TouchableHighlight custom-active-opacity 0.30ms 0.00ms ±0.48ms 1 +0.0%
TouchableHighlight disabled 0.20ms 0.00ms ±0.42ms 1 +0.0%
TouchableHighlight with-all-handlers 0.90ms 0.00ms ±1.85ms 1 +0.0%
TouchableHighlight with-hit-slop 0.60ms 1.00ms ±0.52ms 1 +Infinity%
TouchableHighlight nested-touchables 0.70ms 1.00ms ±0.48ms 1 +0.0%
TouchableHighlight multiple-touchables-10 2.30ms 2.00ms ±0.48ms 1 -33.3%
TouchableHighlight multiple-touchables-50 13.40ms 12.00ms ±3.10ms 1 -4.0%
TouchableHighlight multiple-touchables-100 23.30ms 22.00ms ±4.11ms 1 -2.2%

Pressable

Scenario Mean Median StdDev Renders vs Baseline
Pressable mount 0.40ms 0.00ms ±0.52ms 1 +0.0%
Pressable unmount 0.10ms 0.00ms ±0.32ms 0 +0.0%
Pressable rerender 0.30ms 0.00ms ±0.48ms 2 -100.0%
Pressable with-all-handlers 0.40ms 0.00ms ±0.52ms 1 +0.0%
Pressable with-style-function 0.30ms 0.00ms ±0.48ms 1 +0.0%
Pressable disabled 0.20ms 0.00ms ±0.42ms 1 +0.0%
Pressable with-hit-slop 0.30ms 0.00ms ±0.48ms 1 +0.0%
Pressable nested 0.70ms 1.00ms ±0.48ms 1 +0.0%
Pressable multiple-10 2.80ms 3.00ms ±0.77ms 1 +0.0%
Pressable multiple-50 15.47ms 15.00ms ±3.07ms 1 +7.1%
Pressable multiple-100 15.20ms 10.00ms ±9.47ms 1 -16.7%

Modal

Scenario Mean Median StdDev Renders vs Baseline
Modal mount 0.80ms 1.00ms ±0.42ms 1 +Infinity%
Modal unmount 0.10ms 0.00ms ±0.32ms 0 +0.0%
Modal rerender 0.70ms 1.00ms ±0.67ms 2 +Infinity%
Modal slide-animation 0.80ms 1.00ms ±0.63ms 1 +Infinity%
Modal fade-animation 0.70ms 1.00ms ±0.67ms 1 +Infinity%
Modal transparent 0.80ms 1.00ms ±0.42ms 1 +Infinity%
Modal with-callbacks 0.20ms 0.00ms ±0.42ms 1 +0.0%
Modal rich-content 1.50ms 1.50ms ±0.53ms 1 -25.0%
Modal with-accessibility 0.40ms 0.00ms ±0.52ms 1 +0.0%

Image

Scenario Mean Median StdDev Renders vs Baseline
Image mount 0.20ms 0.00ms ±0.42ms 1 +0.0%
Image unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
Image rerender 0.10ms 0.00ms ±0.32ms 2 +0.0%
Image with-resize-mode 0.20ms 0.00ms ±0.42ms 1 +0.0%
Image with-border-radius 0.20ms 0.00ms ±0.42ms 1 +0.0%
Image with-tint-color 0.10ms 0.00ms ±0.32ms 1 +0.0%
Image with-blur-radius 0.20ms 0.00ms ±0.42ms 1 +0.0%
Image with-accessibility 0.10ms 0.00ms ±0.32ms 1 +0.0%
Image multiple-10 1.07ms 1.00ms ±1.44ms 1 +0.0%
Image multiple-50 3.27ms 3.00ms ±0.59ms 1 +0.0%
Image multiple-100 7.87ms 7.00ms ±2.23ms 1 -12.5%

ActivityIndicator

Scenario Mean Median StdDev Renders vs Baseline
ActivityIndicator mount 0.10ms 0.00ms ±0.32ms 1 +0.0%
ActivityIndicator unmount 0.10ms 0.00ms ±0.32ms 0 +0.0%
ActivityIndicator rerender 0.20ms 0.00ms ±0.42ms 2 +0.0%
ActivityIndicator size-large 0.10ms 0.00ms ±0.32ms 1 +0.0%
ActivityIndicator size-small 0.10ms 0.00ms ±0.32ms 1 +0.0%
ActivityIndicator with-color 0.20ms 0.00ms ±0.42ms 1 +0.0%
ActivityIndicator not-animating 0.10ms 0.00ms ±0.32ms 1 +0.0%
ActivityIndicator with-accessibility 0.20ms 0.00ms ±0.42ms 1 +0.0%
ActivityIndicator multiple-10 0.87ms 1.00ms ±0.35ms 1 +0.0%
ActivityIndicator multiple-50 3.60ms 3.00ms ±1.18ms 1 -25.0%
ActivityIndicator multiple-100 8.33ms 8.00ms ±2.38ms 1 +14.3%

Switch

Scenario Mean Median StdDev Renders vs Baseline
Switch mount 0.30ms 0.00ms ±0.48ms 1 +0.0%
Switch unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
Switch rerender 0.30ms 0.00ms ±0.48ms 2 -100.0%
Switch value-true 0.30ms 0.00ms ±0.48ms 1 +0.0%
Switch disabled 0.20ms 0.00ms ±0.42ms 1 +0.0%
Switch custom-colors 0.30ms 0.00ms ±0.48ms 1 +0.0%
Switch on-value-change 0.10ms 0.00ms ±0.32ms 1 +0.0%
Switch with-accessibility 0.20ms 0.00ms ±0.42ms 1 +0.0%
Switch multiple-10 2.07ms 2.00ms ±1.49ms 1 +0.0%
Switch multiple-50 10.33ms 9.00ms ±4.35ms 1 +0.0%
Switch multiple-100 20.93ms 22.00ms ±3.77ms 1 +37.5%

Button

Scenario Mean Median StdDev Renders vs Baseline
Button mount 0.50ms 0.50ms ±0.53ms 1 -50.0%
Button unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
Button rerender 0.80ms 1.00ms ±0.63ms 2 +0.0%
Button disabled 0.60ms 1.00ms ±0.52ms 1 +0.0%
Button with-color 0.60ms 1.00ms ±0.52ms 1 +100.0%
Button with-accessibility 1.00ms 1.00ms ±1.49ms 1 +0.0%
Button multiple-10 5.87ms 6.00ms ±1.85ms 1 +0.0%
Button multiple-50 21.47ms 24.00ms ±9.33ms 1 -11.1%
Button multiple-100 15.80ms 15.00ms ±2.76ms 1 -21.1%

TextInput

Scenario Mean Median StdDev Renders vs Baseline
TextInput mount 0.10ms 0.00ms ±0.32ms 1 +0.0%
TextInput unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
TextInput rerender 0.20ms 0.00ms ±0.42ms 2 +0.0%
TextInput multiline 0.20ms 0.00ms ±0.42ms 1 +0.0%
TextInput with-value 0.10ms 0.00ms ±0.32ms 1 +0.0%
TextInput styled 0.10ms 0.00ms ±0.32ms 1 +0.0%
TextInput multiple-100 7.20ms 7.00ms ±1.93ms 1 +0.0%

View

Scenario Mean Median StdDev Renders vs Baseline
View mount 0.20ms 0.00ms ±0.42ms 1 +0.0%
View unmount 0.00ms 0.00ms ±0.00ms 0 +0.0%
View rerender 0.30ms 0.00ms ±0.48ms 2 +0.0%
View nested-50 3.27ms 3.00ms ±1.58ms 1 +0.0%
View nested-100 7.87ms 7.00ms ±2.33ms 1 +0.0%
View shadow 0.20ms 0.00ms ±0.42ms 1 +0.0%
View border-radius 0.10ms 0.00ms ±0.32ms 1 +0.0%
View nested-500 18.53ms 12.00ms ±13.38ms 1 +20.0%

Text

Scenario Mean Median StdDev Renders vs Baseline
Text mount 0.10ms 0.00ms ±0.32ms 1 +0.0%
Text unmount 0.10ms 0.00ms ±0.32ms 0 +0.0%
Text rerender 0.10ms 0.00ms ±0.32ms 2 +0.0%
Text long-1000 0.10ms 0.00ms ±0.32ms 1 +0.0%
Text nested 0.20ms 0.00ms ±0.42ms 1 +0.0%
Text styled 0.20ms 0.00ms ±0.42ms 1 +0.0%
Text multiple-100 8.47ms 8.00ms ±2.33ms 1 +14.3%

SectionList.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
SectionList native mount 5.62ms 5.22ms ±1.08ms 1 -19.7%

FlatList.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
FlatList native mount 5.01ms 4.85ms ±0.89ms 1 -47.5%

TouchableHighlight.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
TouchableHighlight native mount 1.50ms 1.47ms ±0.17ms 1 -29.5%

TouchableOpacity.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
TouchableOpacity native mount 1.97ms 1.71ms ±0.79ms 1 -45.5%

Pressable.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
Pressable native mount 1.61ms 1.57ms ±0.18ms 1 -37.4%

ScrollView.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
ScrollView native mount 3.66ms 3.59ms ±0.34ms 1 -11.3%

ActivityIndicator.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
ActivityIndicator native mount 1.61ms 1.42ms ±0.78ms 1 -42.8%

TextInput.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
TextInput native mount 2.27ms 2.20ms ±0.18ms 1 -46.1%

Switch.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
Switch native mount 1.37ms 1.26ms ±0.32ms 1 -27.3%

Button.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
Button native mount 1.93ms 1.87ms ±0.30ms 1 -28.2%

Modal.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
Modal native mount 1.14ms 0.97ms ±0.70ms 1 -20.1%

Image.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
Image native mount 1.72ms 1.64ms ±0.35ms 1 -27.4%

View.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
View native mount 1.14ms 1.06ms ±0.23ms 1 -26.1%

Text.native-perf-test.ts

Scenario Mean Median StdDev Renders vs Baseline
Text native mount 1.31ms 1.33ms ±0.11ms 1 -23.8%

@acoates-ms acoates-ms merged commit 981b29d into microsoft:main May 11, 2026
33 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Invalid Triage https://github.com/microsoft/react-native-windows/wiki/Triage-Process (label applied by bot) label May 11, 2026
acoates-ms added a commit that referenced this pull request May 12, 2026
…16119)

* fix: cancel zombie touch state on ScrollView pointer capture loss (#3) (#16100)

When a touch-screen user scrolls a ScrollView, the OS redirects the
  pointer to the InteractionTracker via TryRedirectForManipulation and
  fires PointerCaptureLost. The existing handler only cleaned up touches
  when JS-level CapturePointer was active (m_pointerCapturingComponentTag
  != -1), which ScrollView never uses. This left a zombie entry in
  m_activeTouches that kept Pressables visually stuck in a pressed state
  and caused subsequent taps to replay events against the original target.

  Three changes:

  1. Extend onPointerCaptureLost to unconditionally cancel the active
     touch for the specific pointer that lost capture, regardless of
     whether JS-level CapturePointer was ever issued.

  2. Remove the always-true fallback in IsPointerWithinInitialTree that
     walked from activeTouch.touch.target (always the initial view) back
     to initialTag, returning true on iteration 1 and bypassing the
     correct W3C hit-test check. This caused onClick to fire even when
     the pointer was released over a different target.

  3. Scope per-pointer event dispatch in DispatchTouchEvent to only the
     pointer that actually changed, instead of iterating every entry in
     m_activeTouches. The old loop fired onPointerDown/Move/Up/Cancel
     for all active touches, producing duplicated events in multi-touch
     scenarios and replaying events on zombie targets.

* Image does not consistently rerender on image source change (#16107)

* Image does not consistently rerender on image source change

* Change files

* fix e2e test?

* Add hideTitleBar and hideBorder to Modal (#16108)

* Add hideTitleBar and hideBorder to Modal

* Change files

* format

* lint fix (type fixes)

* snapshot

* fix: use IsPrimary() for touch pointer isPrimary instead of hardcoded id (#16099)

* Create react-native-windows-4ad3ddaf-1358-4ff0-9971-38a7db68266c.json

* fix: use IsPrimary() for touch pointer isPrimary instead of hardcoded ID check (#4)

activeTouch.isPrimary was set via `pointerId == 1`, which only works for
  mouse (MOUSE_POINTER_ID == 1). Windows touch pointer IDs are OS-allocated
  and essentially never 1, so isPrimary was always false for touch input.
  This meant touch pointers never triggered onClick (gated behind
  isPrimary && button == 0) and reported incorrect isPrimary in
  PointerEvents sent to JS.

  Replace with pointerPoint.Properties().IsPrimary(), which reads the OS
  POINTER_FLAG_PRIMARY flag directly. This API is already used elsewhere
  in the codebase (SwitchComponentView, WindowsTextInputComponentView,
  Composition.Input).

  (The diagnostics are pre-existing clang noise from missing PCH/Windows headers — not
  related to this change.)

* update codegen files

* lint

---------

Co-authored-by: Gordon MacMaster <31481849+gmacmaster@users.noreply.github.com>
@vineethkuttan vineethkuttan removed the Invalid Triage https://github.com/microsoft/react-native-windows/wiki/Triage-Process (label applied by bot) label May 12, 2026
acoates-ms pushed a commit that referenced this pull request May 12, 2026
… id (#16099) (#16121)

* Create react-native-windows-4ad3ddaf-1358-4ff0-9971-38a7db68266c.json

* fix: use IsPrimary() for touch pointer isPrimary instead of hardcoded ID check (#4)

activeTouch.isPrimary was set via `pointerId == 1`, which only works for
  mouse (MOUSE_POINTER_ID == 1). Windows touch pointer IDs are OS-allocated
  and essentially never 1, so isPrimary was always false for touch input.
  This meant touch pointers never triggered onClick (gated behind
  isPrimary && button == 0) and reported incorrect isPrimary in
  PointerEvents sent to JS.

  Replace with pointerPoint.Properties().IsPrimary(), which reads the OS
  POINTER_FLAG_PRIMARY flag directly. This API is already used elsewhere
  in the codebase (SwitchComponentView, WindowsTextInputComponentView,
  Composition.Input).

  (The diagnostics are pre-existing clang noise from missing PCH/Windows headers — not
  related to this change.)
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.

3 participants