Commit Graph

784 Commits

Author SHA1 Message Date
nishan (o^▽^o) b365e26593 feat(iOS) - blur filter using SwiftUI (#52495)
Summary:
As per the discussion on the previous [PR thread](https://github.com/facebook/react-native/pull/52028#issuecomment-2979481948), this PR uses `SwiftUI` to implement blur filter on iOS.

## Approach:

To implement blur filter on iOS, we have two options:

1. Use `CAFilter` (private API, app can get rejected/API can break). Earlier [PR](https://github.com/facebook/react-native/pull/52028) was using that approach. Thanks to Nick for suggesting SwiftUI API.

2. Use `SwiftUI`. Wrap the view in a SwiftUI view and apply [blur](https://developer.apple.com/documentation/swiftui/view/blur(radius:opaque:)). This PR builds on top of that approach. This also enables a way to add `SwiftUI` only features like this one. Additional filters (grayscale, saturate, contrast, hueRotate) can also be added.

There are a few ways we can implement the SwiftUI approach:

1. Create a new `RCTSwiftUIComponentView` -> do style flattening in View -> check if `filter` is present and conditionally render the `RCTSwiftUIComponentView` on iOS, wrap children with a `SwiftUI` view. Tradeoff with this approach is that it adds `StyleSheet.flatten` overhead on JS side.
2. Add a `SwiftUI` container view inside of `RCTViewComponentView`. Tradeoff with this approach is that it complicates `RCTViewComponentView` a bit.

I decided to go with **2** to avoid the flattening tradeoff and try to minimize complicating `RCTViewComponentView`. it only adds the wrapper if it's required and removes if not (in this PR, blur filter style will add the wrapper, it will get removed if blur filter styling gets removed). It uses the existing container view pattern.

## Changelog:
[IOS][ADDED] - Filter blur

<!-- 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

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

Test Plan:
Test filter blur example on iOS. SwiftUI view should be added to the hierarchy.

<img src="https://github.com/user-attachments/assets/742539f4-a96d-45f4-94ba-5eb588d0ad5a" width="300px" />

## Aside:

- This PR also adds a new swift podspec. Creating a new podspec felt the right approach as adding swift in existing ones were adding some complexity. But open for changes here. Also, need some eyes on the podspec configs. cc - chrfalch  🙏   this might also affect the SPM migration.
- Unrelated: Existing brightness filter has some inconsistency compared to android and web, it uses [self.layer.opacity](https://github.com/facebook/react-native/blob/6892dde36373bbef2d0afe535ae818b1a7164f08/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L1008) so transparent background color do not blend well unless the view has an opacity. One solution would be to calculate true background color by using brightness or else use the `SwiftUI`'s [brightness](https://developer.apple.com/documentation/swiftui/view/brightness(_:)), which would be cleaner imo (tested and it works).

Reviewed By: cipolleschi

Differential Revision: D79666764

Pulled By: joevilches

fbshipit-source-id: 05e43d75ce7b6f25b67b4eed632524a559ea1c2e
2025-09-15 15:04:54 -07:00
ismarbesic 07da2ff3e1 feat(ios): support condensed system font on fabric (#52259)
Summary:
This PR adds support for using the condensed system font on iOS when passing "SystemCondensed" as fontFamily. This behavior existed in the old architecture but was never ported to the new one, see [RCTFont.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/React/Views/RCTFont.mm#L434) as reference. Fixes https://github.com/facebook/react-native/issues/52258.

## Changelog:

[IOS] [ADDED] - Add support for condensed system font when using the new react native architecture.

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

Test Plan:
Before:
<img width="275" src="https://github.com/user-attachments/assets/8744a5ae-252c-46db-b5f9-b803f3e1c671" />

After:
<img width="275" src="https://github.com/user-attachments/assets/69ec27a3-5c9a-46e3-a80a-0e02b76d8813" />

Reviewed By: cortinico

Differential Revision: D82208140

Pulled By: javache

fbshipit-source-id: b23a97c94bf45144c3f0860c30e35cae88c7dc2f
2025-09-15 11:31:30 -07:00
Rubén Norte 9962add377 Remove redudant fields from ReactNativeStartupTiming (#53711)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53711

Changelog: [internal]

This removes some fields that contain the same time as `endTime`, which is confusing when documenting them.

Reviewed By: christophpurrer

Differential Revision: D82112473

fbshipit-source-id: 461e2b4b495ae641dcb3233874360a4f7b90dabf
2025-09-11 06:09:29 -07:00
Rubén Norte a16c6c9477 Add feature flag to enable Web Performance APIs by default (#53547)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53547

Changelog: [internal]

This creates a new feature flag to enable the modern Web performance APIs in RN by default. It's disabled by default so it shouldn't have any effect at the moment.

Reviewed By: rshest

Differential Revision: D80811430

fbshipit-source-id: 47d5fd12ac8809aa3c5ad37cdd31c0d9e3ed5912
2025-09-09 08:07:31 -07:00
Sam Zhou 4365c1c9f7 Cleanup codeless suppressions in xplat/js (#53573)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53573

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D81552699

fbshipit-source-id: 71b104174a8ad7fbf360cdd87109ce034f49ec70
2025-09-02 21:56:09 -07:00
Maciej Jastrzębski 0f39fc3000 fix(a11y): aria-hidden support for Text, non-editable TextInput and Image (#53364)
Summary:
Fixes https://github.com/facebook/react-native/issues/53350

This PR adds support for missing `aria-hidden` prop handling on:
- `Text`
- non-editable `TextInput`
- `Image`

The changes are pretty simple and analogous to `View` logic:
- iOS: setting `accessibilityElementsHidden`, `accessible` (for `Image`)
- Android: setting `importantForAccessibility="no-hide-descendents"

Note: [according to MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-hidden) `aria-hidden` should not be used on focusable elements, which excludes editable `TextInput`

## Changelog:

[GENERAL] [FIXED] `aria-hidden` support for `Text`, non-editable `TextInput` and `Image`

<!-- 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

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

Test Plan:
Added new section to RN Tester (APIs => Accessibility => aria-hidden

### After (iOS/Android)

https://github.com/user-attachments/assets/c62f8beb-7cb1-4919-833d-3fb906309cac

https://github.com/user-attachments/assets/78ca5e28-a858-4fd6-ac1c-5ec87872f3fc

### Before (iOS/Android)

https://github.com/user-attachments/assets/84560373-4b31-4793-8997-ee14daa77990

https://github.com/user-attachments/assets/b20074c9-f021-4a90-bce5-75e440a4bbc3

Reviewed By: rshest

Differential Revision: D81043503

Pulled By: javache

fbshipit-source-id: 26b2660a75afcdedba07bee980d8c7f154087ae2
2025-09-01 06:05:43 -07:00
Alex Hunt a4581ecd8b Fix/simplify invariant for ColorSchemeName, align manual typedef (#53397)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53397

This is a runtime behaviour fix and an API change to `Appearance.setColorScheme`, motivated by a user report where providing `'unspecified'` (valid) to this function would trigger an incorrect invariant throw. Furthermore, there is already a [first party use](https://github.com/facebook/react-native/blob/aec35b896053d9372ccdaf67c939b2eb216d3455/packages/react-native/Libraries/Utilities/Appearance.js#L101) where we call `Appearance.setColorScheme('unspecified')`.

**Changes**

- `Appearance.d.ts` (current public API, manual types): Fix `ColorSchemeName` type to include `'unspecified'` value, and narrow to remove nullability — aligning with existing Flow source for this type in `NativeAppearance`.
- `Appearance.js` (implementation): Fix the invariant throw by **removing it**, and instead narrowing the input type to non-nullable. Redundant work in `getState` and `getColorScheme` is removed.

Changelog: [General][Breaking] `Appearance.setColorScheme` no longer accepts a nullable value

Reviewed By: andrewdacenko

Differential Revision: D80705652

fbshipit-source-id: cf221a33447606653050d471ca2d0347ab30db81
2025-08-29 11:42:14 -07:00
Sam Zhou 6c7c518d42 Turn on experimental.natural_inference.local_object_literals.followup_fix in xplat (#53528)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53528

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D81289138

fbshipit-source-id: 05e2f5ad337f616a92df97ea52af8891448e122f
2025-08-29 06:25:57 -07:00
Alex Hunt 63948350e0 Clear XHRExampleFetch interval on unmount (#53481)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53481

Small fix to this RNTester example to clean up hanging `setInterval` side effect making repeat network fetches.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D81127809

fbshipit-source-id: 6036dd254888eb6160d2b1e116bbce63e5fd9328
2025-08-27 09:46:15 -07:00
Sam Zhou 0530ea3349 Migrate to suppression with error code in xplat: 1/n (#53439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53439

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D80809220

fbshipit-source-id: 6f432d8302934b9fee9780ac1d6ba6c87c0b3899
2025-08-22 10:35:39 -07:00
Marco Wang da9136f587 Turn on null strict comparison check for xplat js (#53379)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53379

X-link: https://github.com/facebook/react/pull/34240

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D80648362

fbshipit-source-id: cc47ae207f29a3ddb68bc0e029b8773f89503c52
2025-08-21 16:46:23 -07:00
Marco Wang 8351a5d186 Pre-Suppress errors for xplat/js for general strict comparison in non-generated files (#53342)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53342

Commands

```
scripts/flow/tool add-comments --comment 'Error discovered during Constant Condition roll out. See https://fburl.com/workplace/4oq3zi07.' .
```
```
arc f
```

drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D80487235

fbshipit-source-id: 9e7c1a2641ddc0da0400fa1aff598b112a0434d5
2025-08-19 01:09:22 -07:00
Sam Zhou cf664c65e2 Standardize subtyping error code into incompatible-type in react native and metro (#53312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53312

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D80400976

fbshipit-source-id: 196af69c0b9621b2a2675b232406639773e04933
2025-08-18 09:04:31 -07:00
Maciej Jastrzębski 6965d57e75 fix(a11y): TextInput aria-label handling (#53051)
Summary:
The `aria-label` prop was ignored on `TextInput` component. Which resulted in screen reader not able to read it.

This PR forwards `aria-label` to `accessibilityLabel` in a manner similar to e.g. `View` and `Text`

## 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
-->

[GENERAL] [FIXED] - a11y: fix `aria-label` on `TextInput`

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

Test Plan:
Run RNTester => TextInput => Accessibility section under Accessibility Inspector or screen reader.

iOS fixed:
https://github.com/user-attachments/assets/68c3a2ef-7dfe-479c-97fc-cbe72108c45c

iOS baseline:
https://github.com/user-attachments/assets/2e8372ba-10dc-47d2-b6b1-9f664000de7d

Reviewed By: andrewdacenko

Differential Revision: D79635413

Pulled By: rshest

fbshipit-source-id: dd2f583d67c6c6c6393e02c5fe534308e1e2f921
2025-08-06 09:36:35 -07:00
Sam Zhou af1bcb6d44 Mass replace $FlowIgnore with $FlowFixMe in react-native (#53076)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53076

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D79672242

fbshipit-source-id: 560f057d8658ed602cf7241e584bade70d8f3a99
2025-08-05 15:44:41 -07:00
Sam Zhou 6b354155ed Replace $FlowFixMe(Props|State|Empty) with just $FlowFixMe (#53002)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53002

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D79524515

fbshipit-source-id: 18b96538a62c7ae5912b1e89d2b50c1420c7eaf5
2025-08-04 11:43:00 -07:00
Nick Lefever 5e80759994 Add disabled paragraph prop (#52846)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52846

Adding the Paragraph `disabled` property for RN Android.

This diff also adds a new Text example to RNTester for disabled text.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D78990840

fbshipit-source-id: dd25b890597bc9f728f929b38c2f680631b7f476
2025-07-27 17:20:44 -07:00
Dawid Małecki fb4587780e Move ReactNativeFeatureFlags to src/private (#52610)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52610

This diff removes `ReactNativeFeatureFlags` from `react-native/Libraries/ReactNative` and migrates
`shouldPressibilityUseW3CPointerEventsForHover` to common `ReactNativeFeatureFlags` in `src/private/featureflags`. The `shouldEmitW3CPointerEvents is removed as it is used in `rn-tester` to hide some examples.

Changelog:
[General][Breaking] - Migrate `shouldPressibilityUseW3CPointerEventsForHover` to common private feature flags and remove `shouldEmitW3CPointerEvents` flag.

Reviewed By: robhogan

Differential Revision: D75448698

fbshipit-source-id: 03942c9504b855f2054c9a5948c0521ce17365b5
2025-07-23 01:43:05 -07:00
Nicola Corti 59101d6809 Remove unnecessary OSSLibraryExample (#52705)
Summary:
This module is currently unused, so we can clean it up.

## Changelog:

[INTERNAL] -

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

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D78555763

Pulled By: cortinico

fbshipit-source-id: 0a6152ab3d357cac0c6d7669f292680af7b87074
2025-07-22 03:16:48 -07:00
Sam Zhou 23c8787fe2 Add annotations to fix future errors after fix for unsound array types (#52691)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52691

Unannotated array literals are unsound in Flow right now. This diff adds in annotations and makes a few things readonly, to reduce future errors.

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D78519638

fbshipit-source-id: d98a7668ecf97bcc87dcb3fad25ade736d885d9a
2025-07-17 17:30:43 -07:00
Nick Gerleman 7cd0b42ca0 Add text examples combining textAlign, attachments, script direction, and layout direction (#52445)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52445

This shows some broken stuff (TM), but also asserts current behaviors

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D77702743

fbshipit-source-id: a20d5b09e84d86a16e2443726ac82416b13796a8
2025-07-14 19:43:12 -07:00
Marco Wang 68650badd2 Pre-suppress errors for null_void for xplat js (#52480)
Summary:
Changelog: [Internal]

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

Reviewed By: SamChou19815

Differential Revision: D77890434

fbshipit-source-id: cc0571e0ff1c7cec3fff8614f688d46e46970cc4
2025-07-07 20:35:08 -07:00
Christoph Purrer e8709355dc C++ Turbo Module > Allow Promise<void> types (#52388)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52388

Changelog: [Internal]

Similar to `AsyncCallback<>` (the foundation of `AsyncPromise`) we should allow `void` Promise types in C++ such as `AsyncPromise<>`

Reviewed By: rbergerjr

Differential Revision: D77712020

fbshipit-source-id: d7360df5cc1b77f1e03e5fb73b0b468f6e3a415b
2025-07-06 19:53:51 -07:00
nishan (o^▽^o) 097d482446 fix(ios): Correct gradient interpolation for when transitioning to transparent color (#52249)
Summary:
This change fixes an issue on iOS where gradients that fade to a transparent color-stop appear dark or "muddy." The fix ensures that the color's hue is preserved during the transition, matching the behavior on Android and web.

### The Problem
When creating a gradient on iOS (e.g., linear-gradient(red, transparent)), the transparent keyword is treated as transparent black (rgba(0,0,0,0)). The `CAGradientLayer` on iOS then interpolates all color channels linearly, causing the red, green, and blue components of the start color to fade to 0. This transition through black results in an undesirable dark or "muddy" appearance in the middle of the gradient.

## Changelog:
[IOS][FIXED] - Gradient interpolation for transparent colors
<!-- 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

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

Test Plan:
Checkout `LinearGradient` example in RNTester, checkout the newly added transparent color transition example, it should render same on android and iOS.

| Before | After |
| --- | --- |
| <img src="https://github.com/user-attachments/assets/c0bb54ad-ed0e-4a80-b37f-0458af0f1f77" width="300"> | <img src="https://github.com/user-attachments/assets/02da921a-bd0e-45c1-881c-cf6460d5ed43" width="300"> |
| `linear-gradient(to right, red, transparent)` transitions to black on iOS, creating a dark effect. | The gradient correctly fades the red color's alpha channel to zero |

Reviewed By: javache

Differential Revision: D77312194

Pulled By: NickGerleman

fbshipit-source-id: 053df8e44f52cd22a3f28fd01f583f7d03c66af5
2025-07-02 17:55:45 -07:00
Sam Zhou 505588b9aa Add annotations or make things readonly to prepare for object literal soundness fix in react-native (#52305)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52305

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D77386425

fbshipit-source-id: d69184abb1c8f7c516229aafe24dd418b5dd887e
2025-06-26 13:24:24 -07:00
Sam Zhou 6b85c54ef4 Add annotations to array and object literal declarations to fix future natural inference errors (#52267)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52267

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D77308192

fbshipit-source-id: 21fa2f6d3df632941327b9b2d7910b035f16b7d2
2025-06-25 13:44:09 -07:00
Joe Vilches 7e8eadc041 Fix accessibility order example (#52271)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52271

In my haste I messed up a few of these. Either type in the text, or giving them props they should not have.

Changelog: [Internal]

Reviewed By: jorge-cab

Differential Revision: D77310876

fbshipit-source-id: 9c5a28285d4bb3673fe99630fa7ed97033b17904
2025-06-25 13:06:08 -07:00
nishan (o^▽^o) f238b74658 - Use CAGradientLayer for radial gradient (#52117)
Summary:
This PR replaces Core Graphics implementation with Core Animation for radial gradients. I found that `endPoints` for radial gradient type works differently than linear gradient type. The `endPoint.x` accounts for horizontal length and `endPoint.y` accounts for vertical. This makes it possible to draw ellipse gradients. So we don't need the core graphics API anymore.

## Changelog:

[IOS] [CHANGED] - Optimised Radial Gradients.

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

Pick one each for the category and type tags:

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

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

Test Plan: Non breaking change. Test Radial gradient example from RNTester. Compare results with web, android and iOS. Each platform should render the gradients identically.

Reviewed By: rshest

Differential Revision: D77140709

Pulled By: javache

fbshipit-source-id: 6e3ad9fcf8e819d340ccf5f5946beb140e616cb0
2025-06-24 05:10:30 -07:00
Joe Vilches 62d8d30652 Revamp the accessibility order example in RNTester (#52122)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52122

Would love to have a place with all the edge cases we can come back to when we try and tweak things.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D76942595

fbshipit-source-id: ce6e293e2c068383e54404af71a29a0586dbc04e
2025-06-23 11:07:52 -07:00
nishan (o^▽^o) 2f3b104224 - Use CAGradientLayer for linear gradient (#52096)
Summary:
This PR replaces Core Graphics implementation with Core Animation for linear gradients. I came across a great [solution](https://stackoverflow.com/questions/38821631/cagradientlayer-diagonal-gradient/43176174#43176174) that makes the `CAGradientLayer`'s start and end point behaviour CSS spec compliant. This will make gradients much more performant.

## Changelog:

[IOS] [CHANGED] - Optimised Linear Gradients.
<!-- 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

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

Test Plan:
Non breaking change. Test Linear gradient example from RNTester. Compare results with web, android and iOS. Each platform should render the gradients identically.

## Note:

I will be doing a PR to use `CAGradientLayer` for radial gradients as well. The next properties that I have locally working are `background-size`, `background-position` and `background-repeat`. These will be addressed in small PRs.

Reviewed By: NickGerleman

Differential Revision: D76905215

Pulled By: javache

fbshipit-source-id: 0094bdf70869d619272d491dd496983316b0dbf0
2025-06-19 09:50:45 -07:00
Pieter De Baets 6a3116a8a9 Add screenshot tests for LinearGradient (#52128)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52128

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D76972006

fbshipit-source-id: 657b78a842578df46f81d2416726665f49655a4f
2025-06-19 09:50:45 -07:00
Oskar Kwaśniewski 28986a7599 fix(iOS): allow to interactively swipe down the modal (#51483)
Summary:
This PR allows to interactively close the modal using the swipe down gesture.

It fixes 5 year old issue: https://github.com/facebook/react-native/issues/29319

In short it removes `modalInPresentation` which according to the documentation causes: "UIKit ignores events outside the view controller’s bounds and **prevents the interactive dismissal of the view controller while it is onscreen.**".

It also adds another delegate event to call onRequestClose whenever modal is closed by gesture.

https://github.com/user-attachments/assets/8849ecba-f762-47ec-a28b-b41c1991a882

## Changelog:

[IOS] [ADDED] - Allow to interactively swipe down the modal.
Add allowSwipeDismissal prop.

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

Test Plan: Test if swiping down the modal calls onRequestClose

Reviewed By: rshest

Differential Revision: D75125438

Pulled By: javache

fbshipit-source-id: d4f2c8b59447680f405b725d0809573a937f97cf
2025-06-18 07:18:40 -07:00
Tim Yung ad652cf99c sort-imports: Update Rule Definition (#51880)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51880

Updates the `sort-imports` lint rule.

The main change is that it enforces newlines after the last import statement.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D76149902

fbshipit-source-id: 928871655c5de0613b18334d6fc0d71b3a971a18
2025-06-09 20:30:32 -07:00
Tim Yung 79d2e2a365 RN: Fix Lint for FocusEventsExample.android.js (#51857)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51857

Fixes lint warnings for `FocusEventsExample.android.js`.

Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D76074712

fbshipit-source-id: 10af22f75f03462af35a4fe5e592f8bc8bdc0ca8
2025-06-05 16:18:35 -07:00
Peter Abbondanzo fe66694faf Add example for focus events on Android (#51725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51725

This change builds upon the focus/blur portion showcased in ViewExample but showcases several more components all in one spot. This can be shared with additional platforms or expanded to include more component examples like Image, but the goal is to target Android and not distract from the primary use cases.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D75747410

fbshipit-source-id: 7d53366d9f32192ca6b3da45dd127836fb6efdf6
2025-06-05 13:48:50 -07:00
Tim Yung 3e6423fe65 RN: Flowify packages/rn-tester (#51788)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51788

Adds `flow` to the remaining files that are lacking it in the `packages/rn-tester` directory.

This also adds any necessary type annotations and fixes lint warnings.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75899307

fbshipit-source-id: 27a74ed0007b3b754446a45931c2c148312d5e3a
2025-06-04 12:03:52 -07:00
Mateo Guzmán d3d92b9a1d Unify RNTester Cache Policy Image example (#51580)
Summary:
The Image component in Android now supports the same cache control behaviour as in iOS, the examples needed to be separated in the past because the support was not the same for iOS and Android, but now that it is, we can unify the example.

## Changelog:

[INTERNAL] - Unify RNTester Cache Policy Image example

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

Test Plan:
<details>
<summary>RNTester Screenshots</summary>

| iOS | Android |
|--------|-------|
| ![Simulator Screenshot - iPhone SE (3rd generation) - 2025-05-24 at 12 55 30](https://github.com/user-attachments/assets/f2fd680d-67e4-42db-bc91-f09fe5b0f947) | ![Screenshot_1748084132](https://github.com/user-attachments/assets/ef1b5454-4a85-48d7-be76-3107082b883e) |
</details>

Reviewed By: yungsters

Differential Revision: D75538812

Pulled By: Abbondanzo

fbshipit-source-id: 7705c8f824cb18cebc39e84b6f48979035dc104c
2025-05-31 13:13:39 -07:00
Tim Yung 235b6b180a RN: Fix Unstable Component in FlatList-multiColumn (#51673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51673

Fixes a lint warning that seems to inconsistently fire, by improving the code that it complains about.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D75583443

fbshipit-source-id: b6df191e2e51dee688df3f3c960704dea28a4ece
2025-05-29 02:59:01 -07:00
Peter Abbondanzo 3d7973a3e6 Add focus/blur example to RNTester (#51634)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51634

Creates an example in the ViewExample setup for how onBlur/onFocus behave when using keyboard navigation

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D75238317

fbshipit-source-id: e69122ca17727fc7f71e9bb7a09098a2771b098e
2025-05-28 21:29:51 -07:00
Nick Gerleman dd9d7c0e74 Add Tests for layout events of ellipsized Text (#51666)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51666

The platforms handle this in pretty different ways right now. Let's add a test showing the differences.

Android also adds a bunch of unicode zero width spaces in there...

Changelog: [Internal]

Reviewed By: mlord93

Differential Revision: D75567210

fbshipit-source-id: 98cac7d3fd23451868b55b69478e2667a2de3716
2025-05-28 19:20:55 -07:00
Nick Gerleman 6e8ce60bd4 Implement ReactCompoundView for PreparedLayoutTextView (#51551)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51551

This allows hit RN's hit testing to find nested spans, and click them.

This mechanism is fully separate from the one used by a11y virtual views, and ClickableSpan, such as those added for links via dataDetectorType (and also the `link` role).

When we do have a link accessibilityRole, that ClickableSpan hit test seems to prevent the React one, and we only activate the onPress once (but then add keyboard interaction, press visual, and add to the a11y tree).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D75257326

fbshipit-source-id: 0c693f581ec121cf4b4e3e2040d141985118224f
2025-05-27 17:23:36 -07:00
Mateo Guzmán 9218d1ed89 Fix InputAccessoryView example in dark mode and convert to functional components (#51583)
Summary:
As I reviewed some examples, I noticed that this one's dark mode could be improved, and the code could be modernised a bit as well by converting its classes into functional components.

## Changelog:

[INTERNAL] - Fix InputAccessoryView example in dark mode and convert to functional components

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

Test Plan:
<details>
<summary>Screenshots</summary>

| Dark | Light |
|--------|-------|
| ![Simulator Screenshot - iPhone SE (3rd generation) - 2025-05-24 at 17 39 16](https://github.com/user-attachments/assets/3ed7cb53-89d4-440d-ac4f-50816527774e) | ![Simulator Screenshot - iPhone SE (3rd generation) - 2025-05-24 at 17 39 35](https://github.com/user-attachments/assets/94592d35-859d-4666-a836-977903e955af) |
</details>

Reviewed By: fabriziocucci

Differential Revision: D75404561

Pulled By: cortinico

fbshipit-source-id: 3318e9869919e99055e47b59c89de0b22976f142
2025-05-27 06:44:54 -07:00
Dawid Małecki b34e56259a Remove TextAncestor import from rn-tester TextExample (#51603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51603

In `rn-tester` TextAncestor was used to create a inlineView wrapper:

```js
function InlineView(props) {
  return (
    <TextAncestor.Provider value={false}>
      <View {...props} />
    </TextAncestor.Provider>
  );
}
```

however, it is already done in View.js and TextAncestor shouldn't be used outside of react-native package:

```js
 if (hasTextAncestor) {
    return <TextAncestor value={false}>{actualView}</TextAncestor>;
  }
  return actualView;
```

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D75408231

fbshipit-source-id: 7f12278296dcfe56246f6b7065f5a094e4099f7a
2025-05-27 01:21:17 -07:00
Dawid Małecki 8a0cfec815 Remove infoLog invocations from react-native and rn-tester (#51600)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51600

The `infoLog` is a `console.log` wrapper to separate ad-hoc console debug logging, however console logs are already used in some files in rn-tester (ex. RNTesterAppShared.js). The same applies to files in react-native package.

Changelog:
[General][Changed] - Removed `infoLog` from react-native package

Reviewed By: huntie

Differential Revision: D75402930

fbshipit-source-id: 1a14a9122552130415f058d3647d715225321ab8
2025-05-26 08:19:05 -07:00
Tim Yung 1977dd6596 RN: Sort Pragmas in Headers (#51554)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51554

Sorts pragma directives file headers in React Native.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75264593

fbshipit-source-id: 9e4b253dd0fc94dc2fc469d7114b93a8aae305f4
2025-05-22 21:18:53 -07:00
Nick Gerleman b70c73d8f7 Fix missing height constraints when creating Fabric layout for adjustsFontSizeToFit (#51550)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51550

`adjustsFontSizeToFit` will adjust font size so that given text fits in both veritcal and horizontal bounds. The algorithm to mutate text to fit is executed during TextLayoutManager during layout creation for Fabric, and then re-executed in `TextView.onDraw()`. See D56134348 which introduced the logic.

In Facsimile, we were not seeing font size adjusted when text is too tall. This is because we are only incorporating the height constraint during Spannable mutation during draw, but not the original layout, which Facsimile uses directly.

This could potentially fix other bugs, where width may not corredpond to the final font size we settle on during drawing.

Changelog:
[Android][Fixed] - Fix missing height constraints when creating Fabric layout for `adjustsFontSizeToFit`

Reviewed By: mdvacca

Differential Revision: D75251391

fbshipit-source-id: 77d90c49d48911e63131f9f088cfce13946c67d6
2025-05-22 17:42:29 -07:00
Panos Vekris 0c70c0166e pre-suppress errors for natural inference rollout in xplat/js (#51524)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51524

Links in error suppressions will point to the announcement post in Flow FYI.

Changelog: [Internal]

drop-conflicts

Reviewed By: marcoww6

Differential Revision: D75188177

fbshipit-source-id: 27ea1fbee848e9371e679cf423e30bc9608edea0
2025-05-22 02:50:47 -07:00
Panos Vekris 50ca7e5730 manual annotations in preparation of natural inference rollout in react-native, tools, etc.
Summary:
The Flow team is improving the way Flow infers type for primitive literals. This diff prepares the codebase for the new behavior by adding type annotations, or annotations of the form `'abc' as const`.

Changelog: [internal]

Reviewed By: marcoww6

Differential Revision: D75188179

fbshipit-source-id: be50990f23f79cf2d8dae7576af5190218adcafe
2025-05-21 20:06:46 -07:00
Panos Vekris 1eebb5aa11 Back out "add 'as const' annotations in preparation of natural inference rollout in xplat/js [4/n]"
Summary:
Original commit changeset: 67ee5673816d

Original Phabricator Diff: D75114154

Reviewed By: SamChou19815

Differential Revision: D75161840

fbshipit-source-id: 144fc0e488154b957f4f2a549c077a2784124849
2025-05-21 12:03:51 -07:00
Panos Vekris 2a068c6559 add 'as const' annotations in preparation of natural inference rollout in xplat/js [4/n] (#51488)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51488

The Flow team is improving the way Flow infers type for primitive literals.
Announcement: https://fb.workplace.com/groups/flowlang/permalink/1725180268087629/

This diff prepares the codebase for the new behavior by codemoding `as const` annotations.

## Repro steps

1/ Used steps in D73610163 to produce the code changes.

2/ Reverted files where `flow` errored:
```
flow status --show-all-errors > errors.log
node ~/fbsource/fbcode/flow/facebook/error-analyzer.js errors.log |
  awk -F':' '{ print $1 }' | sort -u | grep -v 'Total Error Count' |
  xargs hg revert --rev .
```

3/ Reverted files that did not improve error count in new Flow mode
```
# Run Flow before change
~/fbsource/fbcode/flow/facebook/flowd status --show-all-errors > errors-0.log
# Run Flow after change
~/fbsource/fbcode/flow/facebook/flowd status --show-all-errors > errors-1.log

# Compute error counts before and after
node ~/fbsource/fbcode/flow/facebook/error-analyzer.js errors-0.log | sort > errors-counts-0.log
node ~/fbsource/fbcode/flow/facebook/error-analyzer.js errors-1.log | sort > errors-counts-1.log

# Revert files with no change in error count
comm -12 errors-counts-0.log errors-counts-1.log | awk -F':' '{ print $1 }' | xargs hg revert --rev .~1
```

## Note to code owners

Due to the large number of errors involved in this rollout, adding `as const` was the most feasible large-scale automated solution. Ideally, a lot of these errors would be fixed by adding other appropriate type annotations. For example instead of annotating
```
type Shape = {type: 'circle', radius: number} | {type: 'square', side: number} | ...;
type ShapeKind = 'circle' | 'square' | 'triangle';
const circle = {
  type: "circle" as const,  // <-- annotation added here
  radius: 42,
};
shape.type as ShapeKind;
takesShape(circle);
```
a more appropriate annotation would be
```
const circle: Circle = { type: "circle"; radius: 42 };
...
```

Changelog: [Internal]

drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D75114154

fbshipit-source-id: 67ee5673816da9625431e2a2466a1e0038386151
2025-05-21 08:42:30 -07:00