Skip to content

fix(view): preserve native behavior when flattening layout-only views - #3172

Open
Jason Morse (JasonVMo) wants to merge 1 commit into
mainfrom
user/jasonvmo/cpp-view-flattening
Open

Jason Morse (JasonVMo) wants to merge 1 commit into
mainfrom
user/jasonvmo/cpp-view-flattening

Conversation

@JasonVMo

Copy link
Copy Markdown

Summary:

The macOS Fabric trait initializer currently treats mouseDownCanMoveWindow=true as requiring a native stacking context, although true is the default in both the C++ props and native view. Consequently every otherwise layout-only View materializes, while an explicit false can lose the native boundary that is meant to prevent window dragging.

  • Require the window-dragging boundary for false, leaving the established true default and Pressable's false override unchanged.
  • Preserve native views and responder boundaries for tooltips, registered drag types and handled key lists when ordinary layout-only Views can flatten again. Keep existing mouse-event, focus, first-mouse and vibrancy requirements.
  • Add two focused tests to the existing stacking-context suite: false/true transitions with a native descendant, and native-only props that must not disappear.

AppKit documents true as permitting mouse-down propagation through superviews. The false override was deliberately added for Pressable cancellation in #1857. This macOS-specific predicate/default mismatch was introduced in #2730; it is not an upstream React Native change. Current main and the pending #3058/#3104/#3105 release-stack trait headers were checked; none contains this correction.

Test Plan:

Built a temporary standalone GoogleTest runner from this branch's actual ViewShadowNode.cpp, existing StackingContextTest.cpp, mounting stubs and component builder. Existing native support libraries/generated headers were reused read-only; no Pods or Xcode build was run. The temporary harness is not part of this PR.

  • bash .flattening-validation/compile_stacking_tests.sh fixed — passed, compiled and linked the runner.
  • .flattening-validation/stacking-tests-fixed --gtest_filter='StackingContextTest.*' — passed all 9 tests, covering both tree builders and incremental mounting mutations.
  • bash .flattening-validation/compile_stacking_tests.sh baseline — passed compilation against the original trait header from 0b569f1497.
  • .flattening-validation/stacking-tests-baseline --gtest_filter='StackingContextTest.defaultPropsMakeEverythingFlattened:StackingContextTest.windowDraggingBoundarySurvivesFlattening:StackingContextTest.macOSNativeBehaviorPreventsFlattening' — expected failure: all 3 fail. Default props produce 10 native stub views instead of 1.
  • bash .flattening-validation/compile_stacking_tests.sh negation-only — passed compilation against a mutation that only negates the mouse-down predicate.
  • .flattening-validation/stacking-tests-negation-only --gtest_filter='StackingContextTest.defaultPropsMakeEverythingFlattened:StackingContextTest.windowDraggingBoundarySurvivesFlattening:StackingContextTest.macOSNativeBehaviorPreventsFlattening' — expected failure: 2 pass, native-prop regression fails, demonstrating why tooltip/drag/key requirements must be retained.
  • bash .flattening-validation/compile_stacking_tests.sh syntax-cxx — passed syntax compilation of production/test sources using cxx host props and -UTARGET_OS_OSX -DTARGET_OS_OSX=0; this is not an iOS runtime/build claim.
  • xcrun clang-format --dry-run --Werror packages/react-native/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewTraitsInitializer.h packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp — passed.
  • git --no-pager diff --check — passed.

Not run: a fresh RNTester-macOS/Pods/Xcode integration build; live window-background dragging and Pressable cancellation; live tooltip/drag-and-drop/keyboard interactions; iOS/visionOS or Paper builds. No screenshots or AppKit runtime verification are claimed. Jest, Flow and ESLint were not run because no JavaScript changed.

Require native window-dragging boundaries for mouseDownCanMoveWindow=false instead of its true default, and preserve native-only tooltip, drag and key behavior when ordinary views flatten. Cover prop transitions and native requirements in the existing stacking-context tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 33ea5c72-8bbd-448d-aa21-c9b99dd03c96
@JasonVMo

Copy link
Copy Markdown
Author

Additional validation: the six independent main fixes (#3170–#3175) were combined at e9667492e9 in an isolated worktree. After regenerating Pods from packages/rn-tester, RNTester-macOS and RNTester for arm64/x86_64 iOS simulators both built successfully. Exact commands, corrected codegen invocation, and limitations are recorded in #3175 (integration validation comment). This is build evidence, not live UI or sanitizer qualification; no PR was merged.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant