Fabric: core Switch renders but never fires onValueChange on mouse click (new architecture)
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Bắt đầu trong vnext/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp, tập trung vào OnPointerPressed, OnPointerReleased và các kiểm tra IsPrimary(). Truy vết xem thao tác nhả chuột có đến được view hay không và gate có chấp nhận thao tác đó hay không, sau đó thêm interaction test được mô tả trong issue. Hoàn tất khi một cú nhấp chuột được tổng hợp phát ra SwitchEventEmitter::onChange và cập nhật Switch được điều khiển.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- react-native-windows 0.83.2 (component source unchanged on
mainas of 2026-07-17), new architecture (Fabric, composition), Win32/HWND host - Windows 11, physical mouse input
- Reproduced in a production app; repro is trivial (any core
Switch)
Steps to reproduce
import {Switch} from 'react-native';
function Repro() {
const [on, setOn] = React.useState(false);
return <Switch value={on} onValueChange={v => { console.log('onValueChange', v); setOn(v); }} />;
}
- Run on react-native-windows with the new architecture enabled.
- Click the Switch with the mouse.
Expected
onValueChange fires with the toggled value; the Switch (a controlled component) re-renders in the new state. This is the behavior on Android/iOS.
Actual
The Switch renders correctly (including hover visuals), but onValueChange never fires on mouse click. No JS callback, no state change — the control is effectively inert for mouse users.
Root cause pointer
vnext/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp (current main):
OnPointerReleased(~line 285) is the only mouse path totoggle()(~line 328), which emitsfacebook::react::SwitchEventEmitter::onChange— the native event behindonValueChange.- Both
OnPointerPressed(~line 262) andOnPointerReleasedearly-return unlessargs.GetCurrentPoint(-1).Properties().IsPrimary()is true.
On our device the emitter never fires for mouse clicks, so either the IsPrimary() gate rejects mouse pointer input on this code path, or OnPointerReleased is never routed to the Switch component view at all (pointer capture/hit-test). We have not stepped through native to disambiguate the two; what is proven on-device is that no onChange event reaches JS for any mouse click, on multiple screens and multiple Switch instances. The keyboard path (OnKeyUp, Space, ~line 318) is separate and was not part of this investigation.
Suggested fix
Ensure the pointer-released path reaches toggle() for mouse input: verify PointerRoutedEventArgs::GetCurrentPoint(-1).Properties().IsPrimary() returns true for mouse-generated pointer events in the composition input pipeline (or drop the IsPrimary() gate for mouse pointer devices), and add an interaction test that asserts SwitchEventEmitter::onChange fires on a synthesized mouse click.
Workaround (what we ship today)
Wrap the Switch in a Pressable that owns the interaction, and make the Switch itself inert:
<Pressable onPress={() => setOn(v => !v)}>
<Switch value={on} pointerEvents="none" />
</Pressable>
The Pressable receives the click and toggles state; the Switch is display-only. This restores mouse operation but bypasses the control's own accessibility/interaction semantics.
- Ngôn ngữ chính
- C++
- Star
- 17.4k
- Fork
- 1.2k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/react-native-windows
-
Fabric text is drawn with ClearType onto transparent composition surfaces, fringing thin glyphsĐang mởNeeds: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/react-native-windows#16340 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug Needs: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/react-native-windows#16321 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Needs: Triage :mag:
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
microsoft/react-native-windows#16442 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Fabric: activating the window doesn't announce the window or the focused control to a screen readerĐang mởNeeds: Triage :mag:
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
microsoft/react-native-windows#16435 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug Needs: Triage :mag:
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
microsoft/react-native-windows#16410 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/react-native-windows
Issue tương tự
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
flashinfer-ai/flashinfer#6212 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug graphics
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
FlaxEngine/FlaxEngine#4295 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Algorithmiq/monoprop#390 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
8-membered-ring atrop stereo lost in 2026.09.1Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 2 ngày