Commit Graph

836 Commits

Author SHA1 Message Date
Nicola Corti d1ef8f1fa3 Make com.facebook.react.views.common.ContextUtils internal (#51959)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51959

This class is public while it should not. It's just internal utilities which we don't really want to expose to 3p users.

I've noticed only one unmaintained libraries (3 year old) that will be affected by this change: https://github.com/phanithken/react-native-pk-image-picker/blob/3c21d0e8e3a797d73806883041500fd546e427d6/android/src/main/java/com/pkimagepicker/PkImagePickerViewHost.kt#L63
So I'm marking this as not breaking.

Changelog:
[Android] [Changed] - Make com.facebook.react.views.common.ContextUtils internal

Reviewed By: alanleedev

Differential Revision: D76429746

fbshipit-source-id: 1677a4b7ae7f2cc2c6c941e7e5fe89a5b332fa20
2025-06-11 12:04:00 -07:00
Nicola Corti 0954c1db45 Remove and cleanup JSEngineResolutionAlgorithm (#51931)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51931

This cleans up the whole `JSEngineResolutionAlgorithm` and all the API related to it.
As now we offer support only for Hermes and JSC is provided via a community package.

This is breaking as it affects Expo, but I'll reach out to Kudo to make sure this is integrated properly.
No other breakages other than this.

Changelog:
[Android] [Removed] - Remove and cleanup JSEngineResolutionAlgorithm

Reviewed By: mdvacca

Differential Revision: D76337620

fbshipit-source-id: e43d5d1164f368f5fa395971bca9c05821492dfe
2025-06-11 03:09:32 -07:00
Mateo Guzmán 0448898213 Migrate ReactFragment to Kotlin (#51756)
Summary:
Migrate com.facebook.react.ReactFragment to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.ReactFragment to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51756

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: javache

Differential Revision: D76255248

Pulled By: cortinico

fbshipit-source-id: 67d289f27f317da10cc68df568cfbf183978c0b4
2025-06-10 07:46:51 -07:00
Mateo Guzmán 8d76670cd5 Migrate ReactPackageTurboModuleManagerDelegate to Kotlin (#51855)
Summary:
Migrate com.facebook.react.ReactPackageTurboModuleManagerDelegate to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.ReactPackageTurboModuleManagerDelegate to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51855

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: fabriziocucci

Differential Revision: D76116517

Pulled By: cortinico

fbshipit-source-id: 76dc4f7e16736a54be2bbfc1e2fa2e64b1433739
2025-06-09 09:13:20 -07:00
Nicola Corti f33fdca876 Convert and internalize MountingManager (#51872)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51872

This converts to Kotlin and internaline MountingManager.

The only usage in OSS is react-natve-live-markdown:
https://github.com/Expensify/react-native-live-markdown/issues/693
They're using reflection to access Mounting Manager, which they shouldn't.

Other than them, I wasn't able to find meaningful usages of `MountingManager`

Changelog:
[Android] [Breaking] - Convert to Kotlin and internalize MountingManager

Reviewed By: rshest

Differential Revision: D76126338

fbshipit-source-id: 5ab491f86d697a82b8e5b02b031877020dfa3e9e
2025-06-09 08:44:02 -07:00
Pieter De Baets 85498ad46f Remove unnecessary receiveCommand overrides (#51844)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51844

These just redefine the existing `receiveCommand` from the ViewManagerDelegate which already has this codegen'ed

Changelog: [Internal]

Reviewed By: cortinico, rshest

Differential Revision: D75869325

fbshipit-source-id: c8ba482075c2586caf33f46a871b5b5e16fda213
2025-06-09 05:49:45 -07:00
Pieter De Baets 198c6fc81c Make receiveCommand args non-nullable (#51806)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51806

Correct the type of args, which is always non-null. This is backwards-compatible as subclasses can override this method with a more permissive nullable type and still be substitutable.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D75869317

fbshipit-source-id: 8f6c9119140794447eca55be24483a35450d7bb6
2025-06-06 22:07:09 -07:00
Peter Abbondanzo e960a28af7 Add focus and blur dispatching logic to BaseViewManager (#51724)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51724

Moves focus change listener logic from `ReactViewManager` to `BaseViewManager` so all view managers that extend the class can get focus/blur event dispatching for free. This does so by applying event listeners where `addEventEmitters` is called, so any extending classes must try to call `super.addEventEmitters` or implement it themselves. In the case of TextInput, this logic is re-implemented because the component emits an additional event when the text input is blurred and I wanted to avoid duplicate calls to get the event emitter for the view instance.

In addition, I've added logic and a test case to ensure that any preexisting focus change listeners set on the view instance are called. There can only ever be one focus change listener tied to a view instance, so this ensures that ones created during view instantiation are retained. However, this does not guarantee that events are emitted for downstream users who overwrite the focus change listener later in the view's lifecycle (i.e. in response to a prop change or an extending view manager that doesn't call `super.addEventEmitters`). There is no clean way to enforce that the `BaseViewManager` focus change listener is always set without changing the generics and introducing a significant breaking change.

Changelog: [Android][Added] - Adds support for onFocus/onBlur event dispatching logic to all native views that implement `BaseViewManager`

Reviewed By: NickGerleman

Differential Revision: D75579321

fbshipit-source-id: 02e1e6d0e78e9d05e4ec5bb59789f3097b73b3f8
2025-06-05 13:48:50 -07:00
Mateo Guzmán d631ec9a6c Migrate ReactTextViewManager to Kotlin (#51721)
Summary:
Migrate com.facebook.react.views.text.ReactTextViewManager to Kotlin.

In this diff, `ReactTextAnchorViewManager` is made public again as it's extended by `ReactTextViewManager`.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.views.text.ReactTextViewManager to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51721

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: mdvacca

Differential Revision: D75829457

Pulled By: NickGerleman

fbshipit-source-id: 425e9ec14f17de5470677b73d68873647bf28675
2025-06-04 21:24:00 -07:00
Nick Gerleman 2ba86caf18 Clean up measurements path and ReactTextViewManagerCallback injection (#51758)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51758

ViewManager’s may implement a measure function (using MapBuffer, or ReadableMap). This isn’t used automatically, but may instead be used, by calling into FabricUIManager via JNI, and passing the component name of the view manager to use.

This is only ever called manually, through specific C++ ShadowNodes. Confusingly, for some cases, like `TextInput`, we use the measure function on `RCTText` instead, because this call to FabricUIManager is hidden behind `TextLayoutManager`. This ends up really breaking Facsimile, since we want to measure these in a different way, while still measuring `TextInput` without preparing a layout.

This mechanism is also used to inject `ReactTextViewManager` from the Text View Manager, into the measurement process, for both Text, and TextInput.

I think we would ideally remove and replace the current View Manager measurement mechanism entirely. The interface doesn’t do what it claims to, and requires calling private Java methods via JNI, which we shouldn’t be encouraging external libraries to do. Only a single 3p librar (react-native-picker) uses this, but we have a lot of internal usages, and the current facility is valuable, for translating surface ID into a context. Ie we could not deprecate it without a well thought out replacement.

Instead, this change:
1. Removes the "generalized" version of this for MapBuffer, only ever used by Text
2. Given ourselves a `measureText` function, that will use a spannable processor provided, but go through TextLayoutManager, instead of trying to use this generalized path
3. Documents some of the weirdness of the current setup, without yet deprecating it

This will let the Facsimile View Manager:
1. Provide a ReactTextViewManagerCallback, like the previous version allowed, that influences measurement of both Text, and TextInput (which is... strange, but... not trying to boil the ocean here)
2. TextInput can now measure text, even if Facsimile View Manager doesn't implement this traditional measure interface

Changelog:
[Android][Breaking] - Remove FabricUIManager.measureMapBuffer() and MapBuffer measure functions on ViewManager. Please use ReadableMap variant.
[Android][Breaking] - Remove FabricUIManager.measure overload which accepts attachment positions

Reviewed By: javache

Differential Revision: D75826792

fbshipit-source-id: 6739b1e2e214351b9b95ba782d73cf4278211ab8
2025-06-04 19:33:30 -07:00
Joe Vilches ed26358f63 Implement textVerticalAlign (#51680)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51680

Right now there are 2 flavors of vertical text alignment: `verticalAlign` and `textVerticalAlign`. Both do the same thing currently. For Facsimile, we actually want to "properly" implement `verticalAlign` so that it matches the web version, while leaving `textVerticalAlign` the same. That will take some time, however, so for now we are just going to implement the way it currently works, while fixing some issues with inline View's

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D75475915

fbshipit-source-id: ba6ff7c831bf769e9e60831ed215ab64faf143a4
2025-06-04 11:39:15 -07:00
Nicola Corti c7bbf120e3 Tweak visibility of fields inside NativeModuleRegistry (#51810)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51810

Tweaking the visiblity of some of the fields `NativeModuleRegistry` after the Kotlin migration
of that class.

Changelog:
[Internal] [Changed] -

Reviewed By: javache

Differential Revision: D75959962

fbshipit-source-id: b3d53fc29af3b0fe32a7bd6a61898814acf90123
2025-06-04 11:19:10 -07:00
Mateo Guzmán dc7be7c7aa Migrate NativeModuleRegistry to Kotlin (#51734)
Summary:
Migrate com.facebook.react.bridge.NativeModuleRegistry to Kotlin.

In this diff, `JavaModuleWrapper` and some of its functions/properties had to be made public again as they are exposed by the migrated class – and if the functions are kept internal, there are crashes in legacy arch due to the C++ usages.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.bridge.NativeModuleRegistry to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51734

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D75938404

Pulled By: cortinico

fbshipit-source-id: 088286d4b100d1013cff43b81db39c6aec10f4e1
2025-06-04 04:53:45 -07:00
Natalia b4ae5c1de1 refactor: migrated file LazyReactPackage to Kotlin (#51085)
Summary:
This PR migrates LazyReactPackage to Kotlin as requested in https://github.com/facebook/react-native/issues/50513.

## Changelog:

[ANDROID] [CHANGED] - Migrate com.facebook.react.LazyReactPackage to Kotlin.

Pull Request resolved: https://github.com/facebook/react-native/pull/51085

Test Plan:
- replaced `BaseReactPackage` with `LazyReactPackage` in `RNTesterApplication.kt`
- run RN tester on old architecture
- executed legacy native module screen

Reviewed By: javache

Differential Revision: D75783140

Pulled By: cortinico

fbshipit-source-id: 9e93f68c6c7ee821a1e0b74649b2438b0dcd4a1a
2025-06-03 10:56:48 -07:00
Nicola Corti 48395d346b Convert ReactViewGroup to Kotlin (#51767)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51767

This is going to convert the last class inside `com.facebook.react.views.view` to Kotlin.

I still need to assess if this is going to be breaking or not for our users. Potentially some
breakages for Kotlin consumer could happen (see changes on ReactViewManager).
I'll follow-up with an investigation on that one.

Changelog:
[Android] [Changed] - Convert ReactViewGroup to Kotlin

Reviewed By: mdvacca

Differential Revision: D75797215

fbshipit-source-id: 5d58faa651d5959909a4b0237aad9c4209895083
2025-06-03 04:56:24 -07:00
Peter Abbondanzo af0a76cf5f Add support for blur and focus on View (#51570)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51570

As the title suggests: adds support strictly to `View` components on Android for `onFocus` and `onBlur` events. This is especially helpful for apps that respond to controller or remote inputs and aligns with existing support for the `focusable` prop.

In order to make this change cross-compatible with text inputs, `TextInputFocusEvent` has been deprecated in favor of the `BlurEvent`/`FocusEvent` types now available from core. Their type signatures are identical but `BlurEvent`/`FocusEvent` should be the type going forward for all views that intend to support focus/blur. Text inputs intentionally do not forward information about their state upon focus/blur and docs specifically call out `onEndEditing` as a means of reading state synchronously when blurring. Therefore, the changes to the native side to remove the event type specifically for text inputs is not breaking.

Changelog: [Android][Added] - Support for `onFocus` and `onBlur` function calls in `View` components

Reviewed By: mdvacca

Differential Revision: D75238291

fbshipit-source-id: b991d1f24fc094ba9d5d466201ecd058f59258e9
2025-05-28 21:29:51 -07:00
Jorge Cabiedes Acosta 2c04b54c05 Fix Custom Focus Ordering for FocusForward, FocusBackward and nested children (#51575)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51575

Before we were relying on absolute focus direction to determine the next focusable view inspired by Recycler View's implementation. This turned out to be inaccurate since FocusForward and FocusBackward do the ordering differently.

For FocusForward and FocusBackwards the children of the root node are ordered first from top to bottom then, row groups are created by getting views with the same vertical position and then everything else is sorted left to right.

Android creates an array with this order and then just focuses the next or previous element of this list. We don't do this but now FocusForward and FocusBackward follow the some comparisons used to build this array on Android.

Also, there was an issue with nested children within an accessible view, this just needed a bit of refactor on the focusSearch function so that we can tell when we actually need to trigger our custom focus search

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D75301251

fbshipit-source-id: 93b708092299afa778ba5938b093c2c38209b497
2025-05-28 14:34:22 -07:00
Nicola Corti 8a04ce6656 Migrate MapBuilder to Kotlin (#51626)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51626

This just migrates the `MapBuilder` file to Kotlin.
Users on Kotlin should still use the built-in collection extensions rather than using this class that will go away at some point in the future.

Changelog:
[Internal] [Changed] -

Reviewed By: fabriziocucci

Differential Revision: D75448739

fbshipit-source-id: 2bfa24ad9bd37bd571ea4551bd9a10e848841e0a
2025-05-27 12:09:16 -07:00
Nicola Corti 2578fd1356 Remove unnecessary OkHttpCompat (#51624)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51624

Let's remove this class and inline all the methods to the callsites.
This class was also public which would make this a breaking change but I couldn't find any meaningful usage:
https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.modules.network.OkHttpCompat

Changelog:
[Internal] [Changed] -

Reviewed By: javache

Differential Revision: D75448162

fbshipit-source-id: 9f4793809c9115a299ac72d79dbfb44073320d54
2025-05-27 09:51:24 -07:00
Nicola Corti 4487697971 Migrate OkHttpCompat to Kotlin (#51625)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51625

This just migrates this class to Kotlin, which is also the last class in this package.

Changelog:
[Internal] [Changed] -

Reviewed By: rshest

Differential Revision: D75448161

fbshipit-source-id: d5457dd8017fd459d166d2945ff440c303943db2
2025-05-27 09:51:24 -07:00
Mateo Guzmán 66aca66c88 Migrate ReactMarker to Kotlin (#51578)
Summary:
Migrate com.facebook.react.bridge.ReactMarker to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.bridge.ReactMarker to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51578

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D75442661

Pulled By: javache

fbshipit-source-id: f05f54f0f68b5a7012312225c28484d57accecf8
2025-05-27 07:43:54 -07:00
Mateo Guzmán c62d9527b4 Reland: Migrate PromiseImpl to Kotlin (#51273)
Summary:
Reland of https://github.com/facebook/react-native/pull/51241, which had to be reverted due to a crash.

Migrate com.facebook.react.bridge.PromiseImpl to Kotlin.

In this diff, nothing has changed yet as from the original PR. Awaiting for next steps to apply new changes https://github.com/facebook/react-native/pull/51241#issuecomment-2873363651

## Changelog:

[INTERNAL] - Migrate com.facebook.react.bridge.PromiseImpl to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51273

Test Plan:
Tested on IGVR here:
https://www.internalfb.com/intern/px/p/7j3zC

Reviewed By: mdvacca, cortinico

Differential Revision: D74645262

Pulled By: javache

fbshipit-source-id: 9d9a439a2e5867a3c7a114cd34277cd59fec864c
2025-05-27 05:53:23 -07:00
Mateo Guzmán bcfa5ca474 Migrate TextAttributes to Kotlin (#51448)
Summary:
Migrate com.facebook.react.views.text.TextAttributes to Kotlin.

`TextTransform` is exposed in the `textTransform` var setter, and there doesn't seem to be a clean way to avoid having to make the `TextTransform` class public again. I have limited its companion to keep it internal as much as possible.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.views.text.TextAttributes to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51448

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: cortinico

Differential Revision: D74978129

Pulled By: rshest

fbshipit-source-id: ea0594f01738b8c8f4696434fe76974bbb9ff661
2025-05-21 03:25:11 -07:00
Tomasz Zawadzki bca7c5a553 Restore the possibility to extend LayoutAnimationController (#51479)
Summary:
In https://github.com/facebook/react-native/pull/50734, `LayoutAnimationController` was migrated to Kotlin and all of its methods are now marked as final.

However, this class is used and extended by `react-native-reanimated` in order to provide Layout Animations for Android on the Old Architecture. With all its methods being marked as final, the builds are failing.

This PR restores the possibility to extend `LayoutAnimationController`.

## Changelog:

[ANDROID] [FIXED] - Restored the possibility to extend `LayoutAnimationController`

Pull Request resolved: https://github.com/facebook/react-native/pull/51479

Test Plan: I've checked that this PR fixes build errors caused by `LayoutAnimationController` in react-native-reanimated.

Reviewed By: cipolleschi, mdvacca

Differential Revision: D75079557

Pulled By: cortinico

fbshipit-source-id: beeb700cbad87362dda4b60941124562c4753815
2025-05-20 12:42:00 -07:00
Christian Falch 2a0c1e6a9e make DevServerHelper open (#51323)
Summary:
Expo inherits from the DevServerHelper class, and needs it to be declared as open, the same goes for its public interface.

Expo is using this in `DevLauncherDevServerHelper` and overrides the methods:

- getDevServerBundleURL
- getDevServerSplitBundleURL
- getSourceUrl
- getSourceMapUrl
- isPackagerRunning

This PR fixes this by adding the open to the class and to the methods that should be open

## Changelog:

[ANDROID] [FIXED] - Made DevServerHelper and its method open so that they can be overridden.

Pull Request resolved: https://github.com/facebook/react-native/pull/51323

Test Plan: Verify that we can build against Expo.

Reviewed By: cipolleschi

Differential Revision: D74876479

Pulled By: cortinico

fbshipit-source-id: 0037d6f7cee190a690ec3ec59896df04f46797b2
2025-05-16 07:52:01 -07:00
Christian Falch 9d11dcd3b0 make removeView open in ViewGroupManager (#51322)
Summary:
After conversion to Kotlin we could no longer override the removeView function since it is no longer open. The rest of this class can be overridden as before, but since functions are final by default this doesn't work for the new `removeView` function.

Expo is overriding the `removeView` functions in `GroupViewManagerWrapper.kt` (a lot of other ViewManager methods are also overridden here, but the `removeView` is introduced in `ViewGroupManager` and needs to be open as well. `GroupViewManagerWrapper.kt` is a replacement view manager that adds support for a delegate that will receive callbacks whenever one of the methods in the view manager are called.

This commit fixes this by making the removeView function explicitly open.

## Changelog:

[ANDROID] [FIXED] - Made function `removeView` open in Kotlin class

Pull Request resolved: https://github.com/facebook/react-native/pull/51322

Test Plan: Verify that Expo can build against this class.

Reviewed By: javache

Differential Revision: D74807744

Pulled By: cortinico

fbshipit-source-id: 55f4b9deccb7d82ceb78be1d56c2b99a6f7e3ce9
2025-05-15 10:36:14 -07:00
Joe Vilches d07b2a9d99 Remove useEditTextStockAndroidBehavior and resolve old android blur issue (#51338)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51338

There was some problems removing this feature flag earlier in that, on older android versions, we would try to focus the top most text input whenever any other text input would try to blur. This was ultimately and issue with how Android implements `clearFocus`. To fix this, lets block the focusability of all views while we clear the focus, then re-enable.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D74760594

fbshipit-source-id: 2811c08ad6ed0855da0a4d7fca89fb08f84905c2
2025-05-15 09:50:32 -07:00
Joe Vilches f6378c3390 Back out "Clean up useEditTextStockAndroidFocusBehavior feature flag"
Summary:
Original commit changeset: 4682cf709aa2

Original Phabricator Diff: D73954790

I want to pick this into 0.80 so users can enable the feature flag so this doesn't break older versions

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D74754010

fbshipit-source-id: 75dc96516b00035984741b43814d6fc7df6be0ac
2025-05-15 09:50:32 -07:00
Joe Vilches 7a04f985fd Back out "Fix issue where text inputs cannot blur on <= Android 8.1" (#51336)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51336

Original commit changeset: 12dcaf0c9c35

Original Phabricator Diff: D74678847

I plan on reverting this so that we can in turn revert the diff that this diff fixed so we can pick it into RN 0.80 so that users have some fix on all versions. Right now 0.80 will be broken for older android devices

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D74754164

fbshipit-source-id: fda17da3e9b61ca13f68f6681726ffb3f4f4f6c0
2025-05-15 09:50:32 -07:00
Joe Vilches 79c47987b7 Fix issue where text inputs cannot blur on <= Android 8.1 (#51302)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51302

We got https://github.com/facebook/react-native/issues/51072#issue-3035616801 which demonstrates that if we have 2 text inputs on a screen we cannot blur them. If you try to blur any, focus jumps to the first one.

This seems to be a bug with Android's `clearFocus` per https://developer.android.com/reference/android/view/View#clearFocus(), this behavior is intended when we are not in touch mode, yet it happens regardless of what mode we are in on this version.

I modified this a bit to swallow `requestFocus` calls if we are in touch mode. This should be fine as no JS focus calls will go through this path. On hardware keyboard focus and focus from `clearFocus`

Changelog: [Android] [Fixed] - Fix bug where focus would jump to top text input upon clearing a separate text input.

Reviewed By: mlord93

Differential Revision: D74678847

fbshipit-source-id: 12dcaf0c9c350d3ed697ff81e8dfb205b7942119
2025-05-13 17:56:46 -07:00
Mateo Guzmán d7b056c198 Migrate JSTouchDispatcher to Kotlin (#51242)
Summary:
Migrate com.facebook.react.uimanager.JSTouchDispatcher to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.JSTouchDispatcher to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51242

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: cortinico

Differential Revision: D74568593

Pulled By: rshest

fbshipit-source-id: 2ce0087ce96025fd85aab2d61806cc9ada1d68cd
2025-05-13 05:05:51 -07:00
Mateo Guzmán 436bddadda Migrate ModuleSpec to Kotlin (#51240)
Summary:
Migrate com.facebook.react.bridge.ModuleSpec to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.bridge.ModuleSpec to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51240

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: cortinico

Differential Revision: D74568550

Pulled By: rshest

fbshipit-source-id: 15cedc9e97f95aa2582ce12c9086336c12564371
2025-05-13 05:03:09 -07:00
Mateo Guzmán d469cca4ba Make SoftAssertions internal (#51172)
Summary:
This class can be internalized as part of the initiative to reduce the public API surface. I've checked there are [no relevant OSS usages](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.bridge.SoftAssertions).

## Changelog:

[INTERNAL] - Make com.facebook.react.bridge.SoftAssertions internal

Pull Request resolved: https://github.com/facebook/react-native/pull/51172

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D74368288

Pulled By: arushikesarwani94

fbshipit-source-id: 50e9559f7f15700ea9adfb03a260615e3b397a0c
2025-05-12 17:22:24 -07:00
Mateo Guzmán 23e693ad67 Make ReactSoftExceptionLogger internal (#51173)
Summary:
This class can be internalized as part of the initiative to reduce the public API surface. I've checked there are [no relevant OSS usages](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.bridge.ReactSoftExceptionLogger).

## Changelog:

[INTERNAL] - Make com.facebook.react.bridge.ReactSoftExceptionLogger internal

Pull Request resolved: https://github.com/facebook/react-native/pull/51173

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D74368261

Pulled By: arushikesarwani94

fbshipit-source-id: 913d790eb64ffda6bb48ddf69dd5ab996cd363d9
2025-05-12 17:22:24 -07:00
HyunWoo Lee b2ffd34a39 Refactor ReactAndroid to use buildReadableMap, buildReadableArray DSL (#51145)
Summary:
This PR refactors the entire ReactAndroid package to replace manual `Arguments.createMap()…` and `Arguments.createArray()…` calls with the new Kotlin DSL helpers `buildReadableMap { … }` and `buildReadableArray { … }`. All eligible call sites have been migrated to the DSL, except in functions whose signatures explicitly declare or return WritableMap or WritableArray.

No runtime behavior changes are introduced; existing functionality and tests continue to pass unchanged.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[ANDROID] [CHANGED] Apply Collections DSL on ReactAndroid package

Pull Request resolved: https://github.com/facebook/react-native/pull/51145

Test Plan:
```
yarn android
yarn test-android
```

Reviewed By: rshest

Differential Revision: D74401357

Pulled By: cortinico

fbshipit-source-id: 0f7b7dfbb7b495675bc4730bdf018666e9041884
2025-05-12 16:35:07 -07:00
Fabrizio Cucci 4918b30f49 Kotlinify ViewManagerRegistry (#51262)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51262

As per title.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D74571782

fbshipit-source-id: 4acec9b9c0801d863074b7a91fb116780f22929a
2025-05-12 13:50:10 -07:00
Mohamed Salama 775c16d8b4 Revert D74567102: Migrate PromiseImpl to Kotlin
Differential Revision:
D74567102

Original commit changeset: 1a7a36a88c04

Original Phabricator Diff: D74567102

fbshipit-source-id: 30814137c711757079fdc574dd21715089b23a25
2025-05-12 10:11:02 -07:00
Pieter De Baets 5413304530 Convert com.facebook.react.runtime.ReactHostImpl to Kotlin (#51017)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51017

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D73846053

fbshipit-source-id: 98017000e8f10df4156b232bc8b5d6e132502ea5
2025-05-12 10:02:19 -07:00
Mateo Guzmán 25abb0acdf Migrate PromiseImpl to Kotlin (#51241)
Summary:
Migrate com.facebook.react.bridge.PromiseImpl to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.bridge.PromiseImpl to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/51241

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D74567102

Pulled By: cortinico

fbshipit-source-id: 1a7a36a88c0499e5bc35dc37d276219aaf823c90
2025-05-12 04:48:28 -07:00
Mateo Guzmán 3a84d42aa1 Make RetryableMountingLayerException internal (#51171)
Summary:
This class can be internalized as part of the initiative to reduce the public API surface. I've checked there are [no relevant OSS usages](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.bridge.RetryableMountingLayerException).

## Changelog:

[INTERNAL] - Make com.facebook.react.bridge.RetryableMountingLayerException internal

Pull Request resolved: https://github.com/facebook/react-native/pull/51171

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D74381780

Pulled By: cortinico

fbshipit-source-id: 6d7255318669ac8edd0010d9655a105e72adf011
2025-05-09 10:40:19 -07:00
Nick Gerleman 99119a2104 Fix TextLayoutManager MeasureMode Regression (#51183)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51183

D58818560 tried to deduplicate some code, but introduced an error, where we no longer correctly incorporate the width MeasureMode into the text layout that we create, instead, passing `YogaMeasureMode.EXACTLY`.

In effect, this means the Android layout created always takes up the maximum allowable space, even if content is smaller. This is later masked, because our returned measure when `AT_MOST` is based on maximum line length, and the layout is then recreated when drawing a TextView, but means:

1. Attachments may not be positioned correctly, when using a non-left-aligned paragraph alignment
2. Directly drawing the layout shows the wrong thing

Changelog:
[Android][Fixed] - Fix TextLayoutManager MeasureMode Regression

Reviewed By: rshest

Differential Revision: D74366936

fbshipit-source-id: 3eda8c716ba9790a61c2da19023e140afbb6971d
2025-05-08 16:18:01 -07:00
Mark Verlingieri a21a4b87c3 Allow fadingEdgeLength to be set independently on the start and end of the scrollview (#51174)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51174

Allows the start and end of the scrollview to be faded to different values independently by passing an object containing a "start" and "end" value to the fadingEdgeLength prop.

To support non-uniform edge lengths we use the [FadingEdgeStrength](https://developer.android.com/reference/android/view/View#getTopFadingEdgeStrength()) api to set different values for the start/end of the scrollview. The FadingEdgeStrength value is multiplied by the FadingEdgeLength value [internally by Android when drawing the view.](https://cs.android.com/android/platform/superproject/+/android15-qpr1-release:frameworks/base/core/java/android/view/View.java;l=25007)

Because the value of FadingEdgeStrength is required to be between 0 and 1, we set setFadingEdgeLength to the max value and set the smaller side as a percentage of that value.

Changelog: [Android][Added] Allow fadingEdgeLength to be set independently on the start and end of the scrollview

Reviewed By: martinbooth

Differential Revision: D74222606

fbshipit-source-id: 7010ca803cc48450ab98c2a457fdc72ff47c29d7
2025-05-08 10:59:32 -07:00
Fabrizio Cucci 090a8da0d1 Kotlinify ReactInstanceManagerInspectorTarget + make internal (#51196)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51196

As per title.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D74325454

fbshipit-source-id: a490614c83bd69660ecdd4cc8439a1a168de3010
2025-05-08 07:47:57 -07:00
Maddie Lord bbc1e121c7 Allow Custom ReactNativeFeatureFlags for Shell 2.0 (#51177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51177

Introduce DefaultNewArchitectureEntryPoint.loadWithFeatureFlags() to allow custom feature flags while using DefaultNewArchitectureEntryPoint

Reviewed By: arushikesarwani94

Differential Revision: D74228467

fbshipit-source-id: ec3fe7edd31cc9713498b316d6306eaa3686398b
2025-05-07 18:58:21 -07:00
Fabrizio Cucci 1908b3dfac Kotlinify JavaScriptModuleRegistry (#51164)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51164

As per title.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D74326679

fbshipit-source-id: ecd15fda9ea8686b65171c462e7e82dc9609377b
2025-05-07 10:34:14 -07:00
Mateo Guzmán a3c9db6122 Make ReactQueueConfigurationImpl internal (#51143)
Summary:
This class can be internalized as part of the initiative to reduce the public API surface. I've checked there are [no relevant OSS usages](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.bridge.queue.ReactQueueConfigurationImpl).

## Changelog:

[INTERNAL] - Make com.facebook.react.bridge.queue.ReactQueueConfigurationImpl internal

Pull Request resolved: https://github.com/facebook/react-native/pull/51143

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest, cortinico

Differential Revision: D74309556

Pulled By: javache

fbshipit-source-id: 1c5eaa0e975bd2db5d451c5e21f14cfa3856e4c3
2025-05-07 05:21:37 -07:00
Mateo Guzmán f81a721b57 Make DebugServerException internal (#51140)
Summary:
This class can be internalized as part of the initiative to reduce the public API surface. I've checked there are [no relevant OSS usages](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.common.DebugServerException).

## Changelog:

[INTERNAL] - Make com.facebook.react.common.DebugServerException internal

Pull Request resolved: https://github.com/facebook/react-native/pull/51140

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: javache

Differential Revision: D74309486

Pulled By: rshest

fbshipit-source-id: 092ffb350d9093deb6b12ad639dd7453027c4c06
2025-05-07 04:54:39 -07:00
David Vacca a254b5e69e Introduce ReactSoftExceptionLogger.CategoryMode to warn categories used on soft errors (#51141)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51141

This diff introduces ReactSoftExceptionLogger.CategoryMode to limit categories used on soft errors, the limiation will only create a lint warning but won't create a compilation error.

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D74263367

fbshipit-source-id: 56fb2ef0ad3d24810172af300e43ecc1f479464f
2025-05-06 15:46:23 -07:00
Nick Gerleman f85b30b24b Underpinnings for Caching Text Layouts (#51065)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51065

This adds infrastructure to let us start storing cached Android text layouts as part of a `ParagraphShadowNode`. After this, we will clear them out, and propagate them to state. Right now, the flag doesn't do much, apart from extra work.

This is done by adding `TextLayoutManagerExtended::supportsPreparedLayout()`, and `TextLayoutManager::PreparedLayout` types, to shim between platforms, then on Android, we add a `PreparedLayout`, which is for now just an Android layout, with extra field (`maxNumberOfLines`, for some reason not exposed on recent versions).

Android `TextLayoutManager` java side is split a little bit, so that we reuse all the existing logic for prepared layouts. I tried to set up the boundary, so that we don't reserialize a MapBuffer after preparation, and for simplicity, this means source of truth for attachment count, and attachment sizes, now lives on the layout. This means we need to change boundary a bit, where we are no longer able to pass in a buffer to fill from C++ side of attachment positions.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D73970149

fbshipit-source-id: ff71c227e062c16fe52a4eb3ba2acbebf3d96e56
2025-05-05 16:48:16 -07:00
Joe Vilches e00028f6bb Clean up useEditTextStockAndroidFocusBehavior feature flag (#51039)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51039

We added a feature flag in case this broke things. Its been about 4 months now with now issues, I think we can clean this up.

Changelog: [Android][Fixed] - Can now focus TextInput with keyboard

Reviewed By: NickGerleman

Differential Revision: D73954790

fbshipit-source-id: 4682cf709aa2f34ba69e76a35d07a908edb28f23
2025-05-02 13:21:27 -07:00