-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deduplicate textInputDid(Begin|End)Editing
calls for multiline <TextInput>
elements
#2159
Deduplicate textInputDid(Begin|End)Editing
calls for multiline <TextInput>
elements
#2159
Conversation
textInputDid(Begin|End)Editing
calls for multiline <TextInput> elementstextInputDid(Begin|End)Editing
calls for multiline <TextInput>
elements
Similar comment as #2160: |
This doesn't repro on iOS, so I have no problem adding |
…xtInput>` elements (microsoft#2159) * Add _isCurrentlyEditing to RCTBaseTextInputView * Move _isCurrentlyEditing check earlier in textInputDidBeginEditing * Adjust comment * nit: remove extra newline * Limit changes to macOS --------- Co-authored-by: Adam Gleitman <[email protected]>
…xtInput>` elements (microsoft#2159) * Add _isCurrentlyEditing to RCTBaseTextInputView * Move _isCurrentlyEditing check earlier in textInputDidBeginEditing * Adjust comment * nit: remove extra newline * Limit changes to macOS --------- Co-authored-by: Adam Gleitman <[email protected]>
) * Deduplicate `textInputDid(Begin|End)Editing` calls for multiline `<TextInput>` elements (#2159) * Add _isCurrentlyEditing to RCTBaseTextInputView * Move _isCurrentlyEditing check earlier in textInputDidBeginEditing * Adjust comment * nit: remove extra newline * Limit changes to macOS --------- Co-authored-by: Adam Gleitman <[email protected]> * Prevent spurious onBlur/onEndEditing events in `<TextInput>` elements with placeholder text (#2160) * Add _isUpdatingPlaceholderText to prevent spurious "did end editing" notifications * Organize macOS tags and ifdef blocks --------- Co-authored-by: Adam Gleitman <[email protected]> --------- Co-authored-by: Adam Gleitman <[email protected]>
) * Deduplicate `textInputDid(Begin|End)Editing` calls for multiline `<TextInput>` elements (#2159) * Add _isCurrentlyEditing to RCTBaseTextInputView * Move _isCurrentlyEditing check earlier in textInputDidBeginEditing * Adjust comment * nit: remove extra newline * Limit changes to macOS --------- Co-authored-by: Adam Gleitman <[email protected]> * Prevent spurious onBlur/onEndEditing events in `<TextInput>` elements with placeholder text (#2160) * Add _isUpdatingPlaceholderText to prevent spurious "did end editing" notifications * Organize macOS tags and ifdef blocks --------- Co-authored-by: Adam Gleitman <[email protected]> --------- Co-authored-by: Adam Gleitman <[email protected]>
## Summary: Merge up to the `0.76-stable` branch cut. ## Interesting commits: - (Not a specific commit): CSS style box shadows are supported by React Native now! I got them.. mostly working on macOS. There's some matrix flipping / coordinate transforms that need to be done to get them completely correct. - facebook@cdab537 (RCTTextInputView.mm) - Adam touched the same code in #2159. Moving the else of `_selectTextOnFocus` for macOS to the reactFocus method - facebook@84fe531 (RCTRedbox.mm) - Meta’s experimenting with Mac Catalyst, and is ignoring safeArea insets on there because it crashes. While macOS doesn’t have a crash using safeAreaInsets, let’s just follow the pattern and not use them in RCTRedbox too - facebook@7653f76 - Border drawing code has significantly changed in RCTViewComponentView - facebook@8d0cbbf - Publish-npm and it's tested needed to be updated to account for this. - facebook@3572ef3 - A fix for RCTImageView.mm that didn't look like it applied to macOS ## Test Plan Box Shadows work! <img width="908" alt="Screenshot 2024-10-20 at 9 12 42 PM" src="https://github.com/user-attachments/assets/194fd907-c4d0-44fd-aacf-e0cbc5de5fbf"> ... but are different in some areas <img width="902" alt="Screenshot 2024-10-20 at 9 13 16 PM" src="https://github.com/user-attachments/assets/23a9cf8b-4f91-4f0b-bcbc-1b5acee95764"> ## Full merge conflict log ``` [react-native-macos] git merge 143f1ad 0.76-merge Auto-merging .github/workflows/autorebase.yml CONFLICT (content): Merge conflict in .github/workflows/autorebase.yml Auto-merging .gitignore Auto-merging Gemfile.lock Auto-merging jest.config.js Auto-merging package.json CONFLICT (content): Merge conflict in package.json Auto-merging packages/babel-plugin-codegen/package.json CONFLICT (content): Merge conflict in packages/babel-plugin-codegen/package.json Auto-merging packages/community-cli-plugin/package.json Auto-merging packages/core-cli-utils/package.json CONFLICT (content): Merge conflict in packages/core-cli-utils/package.json Auto-merging packages/helloworld/package.json Auto-merging packages/react-native-babel-preset/package.json CONFLICT (content): Merge conflict in packages/react-native-babel-preset/package.json Auto-merging packages/react-native-bots/package.json CONFLICT (content): Merge conflict in packages/react-native-bots/package.json Auto-merging packages/react-native-codegen-typescript-test/package.json CONFLICT (content): Merge conflict in packages/react-native-codegen-typescript-test/package.json Auto-merging packages/react-native-codegen/package.json CONFLICT (content): Merge conflict in packages/react-native-codegen/package.json Auto-merging packages/react-native-test-library/package.json CONFLICT (content): Merge conflict in packages/react-native-test-library/package.json Auto-merging packages/react-native-test-renderer/package.json Auto-merging packages/react-native/Libraries/Alert/Alert.js CONFLICT (modify/delete): packages/react-native/Libraries/Animated/NativeAnimatedHelper.js deleted in 143f1ad and modified in HEAD. Version HEAD of packages/react-native/Libraries/Animated/NativeAnimatedHelper.js left in tree. Auto-merging packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h Auto-merging packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm Auto-merging packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm Auto-merging packages/react-native/Libraries/Components/ScrollView/ScrollView.js Auto-merging packages/react-native/Libraries/Components/ScrollView/__tests__/__snapshots__/ScrollView-test.js.snap Auto-merging packages/react-native/Libraries/Components/StatusBar/StatusBar.js Auto-merging packages/react-native/Libraries/Components/TextInput/TextInput.d.ts Auto-merging packages/react-native/Libraries/Components/TextInput/TextInput.js Auto-merging packages/react-native/Libraries/Components/View/ReactNativeViewAttributes.js Auto-merging packages/react-native/Libraries/Components/View/ViewPropTypes.js Auto-merging packages/react-native/Libraries/Image/Image.ios.js Auto-merging packages/react-native/Libraries/Image/RCTImageLoader.mm CONFLICT (content): Merge conflict in packages/react-native/Libraries/Image/RCTImageLoader.mm Auto-merging packages/react-native/Libraries/Image/RCTImageView.mm CONFLICT (content): Merge conflict in packages/react-native/Libraries/Image/RCTImageView.mm Auto-merging packages/react-native/Libraries/Image/RCTResizeMode.h Auto-merging packages/react-native/Libraries/Image/React-RCTImage.podspec CONFLICT (content): Merge conflict in packages/react-native/Libraries/Image/React-RCTImage.podspec Auto-merging packages/react-native/Libraries/Image/__tests__/__snapshots__/Image-test.js.snap Auto-merging packages/react-native/Libraries/Inspector/NetworkOverlay.js Auto-merging packages/react-native/Libraries/LinkingIOS/React-RCTLinking.podspec Auto-merging packages/react-native/Libraries/Lists/FlatList.js Auto-merging packages/react-native/Libraries/Lists/SectionList.js Auto-merging packages/react-native/Libraries/Lists/SectionListModern.js CONFLICT (content): Merge conflict in packages/react-native/Libraries/Lists/SectionListModern.js Auto-merging packages/react-native/Libraries/LogBox/UI/LogBoxInspectorHeader.js Auto-merging packages/react-native/Libraries/Modal/Modal.js Auto-merging packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm Auto-merging packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h Auto-merging packages/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.mm Auto-merging packages/react-native/Libraries/Network/React-RCTNetwork.podspec Auto-merging packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts Auto-merging packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js Auto-merging packages/react-native/Libraries/Text/BaseText/RCTBaseTextViewManager.mm Auto-merging packages/react-native/Libraries/Text/RCTTextAttributes.h Auto-merging packages/react-native/Libraries/Text/RCTTextAttributes.mm Auto-merging packages/react-native/Libraries/Text/React-RCTText.podspec CONFLICT (content): Merge conflict in packages/react-native/Libraries/Text/React-RCTText.podspec Auto-merging packages/react-native/Libraries/Text/Text/RCTTextShadowView.mm Auto-merging packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm Auto-merging packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm CONFLICT (content): Merge conflict in packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm Auto-merging packages/react-native/Libraries/Text/TextNativeComponent.js Auto-merging packages/react-native/Libraries/Utilities/Appearance.js CONFLICT (content): Merge conflict in packages/react-native/Libraries/Utilities/Appearance.js Auto-merging packages/react-native/Libraries/Utilities/HMRClient.js Auto-merging packages/react-native/Libraries/Utilities/ReactNativeTestTools.js Auto-merging packages/react-native/Libraries/WebSocket/WebSocket.js Auto-merging packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap CONFLICT (content): Merge conflict in packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap Auto-merging packages/react-native/React/Base/RCTBridge.mm Auto-merging packages/react-native/React/Base/RCTConvert.h CONFLICT (content): Merge conflict in packages/react-native/React/Base/RCTConvert.h Auto-merging packages/react-native/React/Base/RCTConvert.mm CONFLICT (content): Merge conflict in packages/react-native/React/Base/RCTConvert.mm Auto-merging packages/react-native/React/Base/RCTKeyCommands.m CONFLICT (content): Merge conflict in packages/react-native/React/Base/RCTKeyCommands.m Auto-merging packages/react-native/React/CoreModules/RCTAppearance.mm Auto-merging packages/react-native/React/CoreModules/RCTDevLoadingView.mm Auto-merging packages/react-native/React/CoreModules/RCTDevMenu.mm Auto-merging packages/react-native/React/CoreModules/RCTDeviceInfo.mm CONFLICT (content): Merge conflict in packages/react-native/React/CoreModules/RCTDeviceInfo.mm Auto-merging packages/react-native/React/CoreModules/RCTPerfMonitor.mm CONFLICT (content): Merge conflict in packages/react-native/React/CoreModules/RCTPerfMonitor.mm Auto-merging packages/react-native/React/CoreModules/RCTPlatform.mm Auto-merging packages/react-native/React/CoreModules/RCTRedBox.mm CONFLICT (content): Merge conflict in packages/react-native/React/CoreModules/RCTRedBox.mm Auto-merging packages/react-native/React/CoreModules/RCTStatusBarManager.mm Auto-merging packages/react-native/React/CoreModules/React-CoreModules.podspec Auto-merging packages/react-native/React/CxxBridge/RCTCxxBridge.mm Auto-merging packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm CONFLICT (content): Merge conflict in packages/react-native/React/DevSupport/RCTInspectorDevServerHelper.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm CONFLICT (content): Merge conflict in packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm CONFLICT (content): Merge conflict in packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm CONFLICT (content): Merge conflict in packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm Auto-merging packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm CONFLICT (content): Merge conflict in packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm Auto-merging packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm Auto-merging packages/react-native/React/Fabric/RCTSurfacePresenter.mm Auto-merging packages/react-native/React/Modules/RCTRedBoxExtraDataViewController.m Auto-merging packages/react-native/React/React-RCTFabric.podspec Auto-merging packages/react-native/React/Views/RCTBorderDrawing.h Auto-merging packages/react-native/React/Views/RCTBorderDrawing.m Auto-merging packages/react-native/React/Views/RCTComponentData.m Auto-merging packages/react-native/React/Views/RCTModalHostView.m Auto-merging packages/react-native/React/Views/RCTModalHostViewController.m CONFLICT (content): Merge conflict in packages/react-native/React/Views/RCTModalHostViewController.m Auto-merging packages/react-native/React/Views/RCTModalHostViewManager.m Auto-merging packages/react-native/React/Views/RCTView.m CONFLICT (content): Merge conflict in packages/react-native/React/Views/RCTView.m Auto-merging packages/react-native/React/Views/RCTViewManager.h Auto-merging packages/react-native/React/Views/RCTViewManager.m Auto-merging packages/react-native/React/Views/RefreshControl/RCTRefreshControl.m Auto-merging packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java Auto-merging packages/react-native/ReactCommon/react/nativemodule/samples/platform/ios/ReactCommon/RCTSampleTurboModule.mm Auto-merging packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm CONFLICT (content): Merge conflict in packages/react-native/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm Auto-merging packages/react-native/ReactCommon/react/renderer/components/view/BaseViewProps.h Auto-merging packages/react-native/ReactCommon/react/renderer/components/view/conversions.h Auto-merging packages/react-native/ReactCommon/react/renderer/components/view/primitives.h Auto-merging packages/react-native/ReactCommon/react/renderer/graphics/React-graphics.podspec Auto-merging packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm Auto-merging packages/react-native/ReactCommon/react/renderer/imagemanager/platform/ios/react/renderer/imagemanager/RCTImagePrimitivesConversions.h Auto-merging packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.h Auto-merging packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm Auto-merging packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm Auto-merging packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm Auto-merging packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextPrimitivesConversions.h Auto-merging packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHermesInstance.h Auto-merging packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h Auto-merging packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm Auto-merging packages/react-native/index.js Auto-merging packages/react-native/package.json CONFLICT (content): Merge conflict in packages/react-native/package.json Auto-merging packages/react-native/react-native.config.js CONFLICT (content): Merge conflict in packages/react-native/react-native.config.js Auto-merging packages/react-native/scripts/cocoapods/__tests__/codegen_utils-test.rb Auto-merging packages/react-native/scripts/cocoapods/helpers.rb Auto-merging packages/react-native/scripts/cocoapods/utils.rb Auto-merging packages/react-native/scripts/react-native-xcode.sh Auto-merging packages/react-native/scripts/react_native_pods.rb Auto-merging packages/react-native/sdks/hermes-engine/hermes-engine.podspec CONFLICT (modify/delete): packages/react-native/template/package.json deleted in 143f1ad and modified in HEAD. Version HEAD of packages/react-native/template/package.json left in tree. Auto-merging packages/rn-tester/Podfile.lock CONFLICT (content): Merge conflict in packages/rn-tester/Podfile.lock Auto-merging packages/rn-tester/RNTester/AppDelegate.mm Auto-merging packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj CONFLICT (content): Merge conflict in packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj Auto-merging packages/rn-tester/RNTesterUnitTests/RCTAllocationTests.m Auto-merging packages/rn-tester/js/components/RNTPressableRow.js CONFLICT (content): Merge conflict in packages/rn-tester/js/components/RNTPressableRow.js Auto-merging packages/rn-tester/js/components/RNTesterModuleContainer.js Auto-merging packages/rn-tester/js/components/RNTesterModuleList.js CONFLICT (content): Merge conflict in packages/rn-tester/js/components/RNTesterModuleList.js Auto-merging packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js Auto-merging packages/rn-tester/js/examples/Border/BorderExample.js Auto-merging packages/rn-tester/js/examples/Image/ImageExample.js Auto-merging packages/rn-tester/js/examples/Layout/LayoutEventsExample.js Auto-merging packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js CONFLICT (content): Merge conflict in packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js Auto-merging packages/rn-tester/js/examples/Pressable/PressableExample.js Auto-merging packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js Auto-merging packages/rn-tester/js/examples/Snapshot/SnapshotExample.js Auto-merging packages/rn-tester/js/examples/Text/TextExample.ios.js Auto-merging packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js Auto-merging packages/rn-tester/js/examples/Touchable/TouchableExample.js Auto-merging packages/rn-tester/js/types/RNTesterTypes.js Auto-merging packages/rn-tester/js/utils/RNTesterList.ios.js Auto-merging packages/rn-tester/package.json CONFLICT (content): Merge conflict in packages/rn-tester/package.json Auto-merging packages/virtualized-lists/Lists/VirtualizedList.js Auto-merging packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js Auto-merging packages/virtualized-lists/Lists/VirtualizedListProps.js Auto-merging packages/virtualized-lists/package.json CONFLICT (content): Merge conflict in packages/virtualized-lists/package.json Auto-merging scripts/releases-ci/__tests__/publish-npm-test.js CONFLICT (content): Merge conflict in scripts/releases-ci/__tests__/publish-npm-test.js Auto-merging scripts/releases-ci/publish-npm.js CONFLICT (content): Merge conflict in scripts/releases-ci/publish-npm.js Auto-merging scripts/releases/utils/release-utils.js CONFLICT (content): Merge conflict in scripts/releases/utils/release-utils.js Auto-merging yarn.lock CONFLICT (content): Merge conflict in yarn.lock Automatic merge failed; fix conflicts and then commit the result. ```
Summary:
We recently found a bug where after editing a multiline
<TextInput>
withautoFocus={true}
causestextInputDidBeginEditing
to be called twice: once on accepting focus, and again when we start typing. If the text input already has text in it, the second call has a side effect of moving the cursor to the end, which is undesirable if the used moved the cursor somewhere to the middle.This appears to only repro for multiline text inputs, which are backed by
NSTextView
instead ofNSTextField
. As of now, it's unknown why these behave differently, and since these events come from AppKit itself, we don't have as much control over them. Our solution is to add an extra bit of state so we can enforce that the effects of these calls don't get duplicated.For added correctness, we add similar deduplication for
textInputDidEndEditing
to ensure that everyDidBegin
can be accompanied by exactly oneDidEnd
.Test Plan:
Validated using the following test code (which was adapted from a previous test case involving programmatic editing of a
<TextInput>
's content).