Commit Graph
20 Commits
Author SHA1 Message Date
Nick GerlemanandBlake Friedman 3ce4b80e6f Include existing attributes in newly typed text (#47018)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47018

This change makes it so that newly typed text in a TextInput will include the existing attributes present based on cursor position. E.g. if you type after an inner fragment with blue text, the next character will be blue (or, an event emitter specific to an inner fragment will also be expanded). This is a behavior change for the (admittedly rare) case of uncontrolled TextInput with initially present children AttributedText, but more often effect controlled components, before state update (we are after, less likely to need to reset AttributedString because of mismatch).

Originally included this in D64121570, but it's not needed to fix the common case since we include paragraph-level event emitter as part of default attributes, and has some of its own risk, so I decided it is better separate.

Changelog:
[iOS][Changed] - Include existing attributes in newly typed text

Reviewed By: cipolleschi

Differential Revision: D64352310

fbshipit-source-id: 90ef8c49f50186eadf777e81cf6af57e1aada207
2024-11-12 18:58:46 +00:00
Elene BotchoradzeandFacebook GitHub Bot 26aff664c0 fix(ios): removed default value (#46020)
Summary:
Removed UIReturnKeyDefault as it caused bug when there wasn't any type.

## Changelog:

[IOS] [REMOVED]: UIReturnKeyDefault

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

Reviewed By: christophpurrer

Differential Revision: D61277058

Pulled By: cipolleschi

fbshipit-source-id: 18349c49b05d492a2c2ed5713af3ceb6d3728e70
2024-08-15 08:10:08 -07:00
Oskar KwaśniewskiandFacebook GitHub Bot e4e461c9cf feat: implement automicallyAdjustsKeyboardInsets for new architecture on iOS (#45939)
Summary:
This PR implements the missing `automicallyAdjustsKeyboardInsets` for new architecture. It's a fixed version of reverted: https://github.com/facebook/react-native/issues/45819

We now check if the view intersects with the keyboard's end frame and if it doesn't we just do nothing.

Here is the app running on new arch:

https://github.com/user-attachments/assets/673f0587-6a67-47e3-8050-d6ee33a45724

## Changelog:

[IOS] [FIXED] - implement automicallyAdjustsKeyboardInsets for new arch

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

Test Plan:
1. Test out ScrollViewKeyboardInsets example
2. See if it works the same with old and new arch

Reviewed By: cortinico

Differential Revision: D60958475

Pulled By: cipolleschi

fbshipit-source-id: 8650064af84bc79b6b89e07293640e5d010154c2
2024-08-09 05:22:23 -07:00
Omar Manjarrez OsornioandFacebook GitHub Bot fb67612e0b Revert D60453404: feat(iOS): implement automicallyAdjustsKeyboardInsets for new arch
Differential Revision:
D60453404

Original commit changeset: bd7ce5bac8fa

Original Phabricator Diff: D60453404

fbshipit-source-id: cda549be11288fa6cda03a4e6798125bac3c95e2
2024-08-06 15:36:52 -07:00
Oskar KwaśniewskiandFacebook GitHub Bot 21bdce7286 feat(iOS): implement automicallyAdjustsKeyboardInsets for new arch (#45819)
Summary:
This PR implements the missing `automicallyAdjustsKeyboardInsets` for new architecture.

After fixing this I've noticed there is an open issue (https://github.com/facebook/react-native/issues/45647) with somebody assigned (sorry shubhamguptadream11 for taking your task)

Here is the app running on new arch:

https://github.com/user-attachments/assets/673f0587-6a67-47e3-8050-d6ee33a45724

## Changelog:

[IOS] [FIXED] - implement automicallyAdjustsKeyboardInsets for new arch

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

Test Plan:
1. Test out ScrollViewKeyboardInsets example
2. See if it works the same with old and new arch

Reviewed By: sammy-SC

Differential Revision: D60453404

Pulled By: cipolleschi

fbshipit-source-id: bd7ce5bac8facffc527106b50c54112acf687bc3
2024-08-06 04:15:49 -07:00
shubhamguptadream11andFacebook GitHub Bot ead50d6b11 fix: added showSoftInputFocus handling for iOS new architecture (#45298)
Summary:
Fixes: https://github.com/facebook/react-native/issues/45297

In iOS New Architecture When we are passing `showSoftInputOnFocus` prop to TextInput as false it should prevent soft keyboard from showing.
Here, the problem is in Fabric counterpart of TextInput, there we are not handling `showSoftInputOnFocus` props anywhere.

## Changelog:

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

Pick one each for the category and type tags:

[iOS] [ADDED] - Added handling of `showSoftInputOnFocus` props for new arch.

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

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

Test Plan:
Below is the screen recording of fix made.

https://github.com/facebook/react-native/assets/85783070/de94877a-f684-4f8d-9ec4-a16f9755663e

Reviewed By: cipolleschi

Differential Revision: D59447432

Pulled By: dmytrorykun

fbshipit-source-id: 240854bc1101bdf0b04d7978c557215ff3f8a449
2024-07-08 07:19:38 -07:00
HaileyandFacebook GitHub Bot cdab5370af fix (iOS): fix selectTextOnFocus in Fabric and non-Fabric by calling selectAll after becomeFirstResponder (#44307)
Summary:
Fixes https://github.com/facebook/react-native/issues/41988

Hopefully even if this isn't the right way to go about solving this, it at least points in the right direction for a different fix!

Currently - both on Paper and Fabric - the `selectTextOnFocus` prop does not work as expected on a single line text input. It seems that if the `UITextField` has not yet become the first responder, the text will be briefly selected but then deselected immediately afterward.

This can be seen in the tester when running for either Fabric or Paper (video using Fabric)

https://github.com/facebook/react-native/assets/153161762/aa9c609e-6eb8-4177-a41f-32aae53c06ac

Instead, we can move the `selectAll` call to `reactFocus` in `RCTBaseTextInputView` or `focus` `RCTTextInputComponentView` - both of which first call `becomeFirstResponder` - to get the expected result.

## Changelog:

[IOS] [FIXED] - fix selectTextOnFocus in Fabric and non-Fabric by calling selectAll after becomeFirstResponder

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

Test Plan:
* Test changes on RN Tester (iOS)

 https://pxl.cl/55kDc

Reviewed By: cipolleschi

Differential Revision: D56699773

Pulled By: fabriziocucci

fbshipit-source-id: ed092835f3c602e2c50a4198357653a9cef942d9
2024-06-18 08:44:09 -07:00
Elene BotchoradzeandFacebook GitHub Bot ed9978b8de feat(iOS): add all supported ReturnKeyTypes (#43362)
Summary:
Related issue: https://github.com/facebook/react-native/issues/43243
As [documentation](https://reactnative.dev/docs/textinput#returnkeytype) stated for the ReturnKeyType prop on the input there are different options, like "next", "go" and etc. They are actually supported on the iOS side but we can't use it in our react native app, because of the hardcoded version of DoneButton on existing code:
<img width="887" alt="image" src="https://github.com/facebook/react-native/assets/53994979/9ecaf63b-675c-45f0-b737-7ae3e937584a">
So, I decided to add support for types which were in documentation

## Changelog:
[IOS] [ADDED]: ReturnKeyTypes
<!-- 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/43362

Test Plan:
ran yarn jest react-native-codegen and yarn jest react-native, both successfully:
<img width="420" alt="image" src="https://github.com/facebook/react-native/assets/53994979/c36b61f7-ef45-4062-ac5b-1dd2d0a9e544">

<img width="420" alt="image" src="https://github.com/facebook/react-native/assets/53994979/af83c22c-d110-4c28-94c1-d48ee27bfcfe">

Reviewed By: cortinico

Differential Revision: D56571845

Pulled By: cipolleschi

fbshipit-source-id: 74dbffb3795ab0b5c9eafa685761c2e770cd5cf9
2024-06-06 09:21:49 -07:00
Nick GerlemanandFacebook GitHub Bot d1e8328f7e Add QualifierAlignment to Clang Format Config (#44098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44098

This sets `QualiferAlignment` so that code is automatically formatted to west const.

I did a pass at this before, but now that we are on new Clang Format, we can enforce it automatically, and I think a couple more cases not previously changed now are.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56143678

fbshipit-source-id: 8f12b288476ea6019fd7d7a93a39b4fe2e75af14
2024-04-15 16:03:26 -07:00
Fabrizio BertoglioandFacebook GitHub Bot f6badca2f9 Fix Multiline TextInput with a fixed height scrolls to the bottom when prepending new lines to the text (#38679)
Summary:
### Please re-state the problem that we are trying to solve in this issue.

Multiline TextInput with a fixed height will scroll to the bottom of the screen when prepending new lines to the text.

### What is the root cause of that problem?

The issue is caused by iOS UITextView:
- The cursor moves to the end of the text when prepending new lines.
- Moving the cursor to the end of the text triggers the scroll to the bottom.

The behavior was reproduced on an iOS App (without react-native).
The example included below implements a Component RCTUITextView based on UITextView, which modifies the UITextView attributedText with the textViewDidChange callback (source code available in this [comment](https://github.com/Expensify/App/issues/19507#issuecomment-1595730348)).

Adding a new line on top of the UITextView on iOS results in:
Issue 1) The cursor moves to the end of TextInput text
Issue 2) The TextInput scrolls to the bottom

<details><summary>Reproducing the issue on an iOS App without react-native</summary>
<p>

<video src="https://user-images.githubusercontent.com/24992535/246601549-99f480f3-ce80-4678-9378-f71c8aa67e17.mp4" width="900" />

</p>
</details>

Issue 1) is already fixed in react-native, which restores the previous cursor position (on Fabric with  [_setAttributedString](https://github.com/fabriziobertoglio1987/react-native/blob/71e7bbbc2cf21abacf7009e300f5bba737e20d17/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L600-L610)) after changing the text.
Issue 2) needs to be fixed in react-native.

### What changes do you think we should make in order to solve the problem?

Setting the correct TextInput scroll position after re-setting the cursor.

## Changelog:

[IOS] [FIXED] - Fix Multiline TextInput with a fixed height scrolls to the bottom when changing AttributedText

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

Test Plan:
Fabric (reproduces on controlled/not controlled TextInput example):

| Before    | After |
| ----------- | ----------- |
| <video src="https://github.com/facebook/react-native/assets/24992535/e06b31fe-407d-4897-b608-73e0cc0f224a" width="350" />      | <video src="https://github.com/facebook/react-native/assets/24992535/fa2eaa31-c616-43c5-9596-f84e7b70d80a" width="350" />       |

Paper (reproduces only on controlled TextInput example):

```javascript
function TextInputExample() {
  const [text, setText] = React.useState('');

  return (
    <View style={{marginTop: 200}}>
      <TextInput
        style={{height: 50, backgroundColor: 'white'}}
        multiline={true}
        value={text}
        onChangeText={text => {
          setText(text);
        }}
      />
    </View>
  );
}
```

| Before    | After |
| ----------- | ----------- |
| <video src="https://github.com/facebook/react-native/assets/24992535/6cb1f2de-717e-4dce-be0a-644f6a051c08" width="350" />      | <video src="https://github.com/facebook/react-native/assets/24992535/dee6edb6-76c6-48b0-b78f-99626235d30e" width="350" />       |

Reviewed By: sammy-SC, cipolleschi

Differential Revision: D48674090

Pulled By: NickGerleman

fbshipit-source-id: 349e7b0910e314ec94b45b68c38571fed41ef117
2024-03-28 16:05:06 -07:00
Samuel SuslaandFacebook GitHub Bot 06dc448d85 use structs instead of class for TextInputMetrics and KeyPressMetrics (#43510)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43510

changelog: [internal]

- use designated initializers.
- make TextInputMetrics and KeyPressMetrics structs.
- move TextInputMetrics and KeyPressMetrics inside of TextInputEventEmitter.
- Utilise RCTSizeFromCGSize, RCTEdgeInsetsFromUIEdgeInsets and RCTPointFromCGPoint when creating  TextInputMetrics.

Reviewed By: rshest

Differential Revision: D54895928

fbshipit-source-id: 4afd49ffa77c5afafc794808aac7f11bb8213944
2024-03-16 12:12:46 -07:00
Samuel SuslaandFacebook GitHub Bot 2ed1e9ad28 remove sync events from TextInput (#43429)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43429

changelog: [internal]

these experimental props have served their purpose and can be deleted.

Reviewed By: rubennorte

Differential Revision: D54682805

fbshipit-source-id: aee5072e2aa056c862f369426617d0d51c98997f
2024-03-12 04:32:01 -07:00
Pieter De BaetsandFacebook GitHub Bot f1dc061fce Use defaultSharedProps in ComponentView init (#41623)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41623

`static` fields require additional code to ensure the field is only ever initialized once. We already have a static "default props" field in the shadow node, so let's reuse that as much as possible.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D51547638

fbshipit-source-id: e4957ffb0f9352847b8cd8dc3a010dcfac8be699
2023-11-23 14:05:17 -08:00
Nick GerlemanandFacebook GitHub Bot a966291611 Consistent QualifierAlignment (for real this time I swear) (#39217)
Summary:
(reland of D48761722)

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

React Native uses an inconsistent mix of "west const" and "east const". E.g. `const auto &` in 74 files, but `auto const &` in 60. Sometimes they are mixed from one line to the next:  {F1079102436}

Clang format 14 adds a QualifierAlignment option, but fbsource is still on 12, so we cannot use it in our config until the [world is updated]()https://fb.workplace.com/groups/toolchain.fndn/posts/24006558685624673/?comment_id=24009214565359085&reply_comment_id=24009455088668366. This diff just runs a local version of Clang format locally first to fix QualifierAlignment, then reformats with the fbsource version, to fix any other output differences unrelated to that. This will not continually enforce a style, but will make the world more consistent, and hopefully encourage a consistent style until we can set it.

West const seems more popular in `//xplat` so I just picked left alignment somewhat arbitrarily, but we could also maybe take a poll on this.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48852450

fbshipit-source-id: 1789aa0db43948169f482188cb8b5e8f0f0246b8
2023-08-30 19:56:13 -07:00
Ken TominagaandFacebook GitHub Bot 04d1de5896 Remove iOS 12 version check (#33460)
Summary:
I removed the code checking iOS 12 availability because the iOS minimum deployment target is now iOS 12.4 after these commits (https://github.com/facebook/react-native/commit/982ca30de079d7e80bd0b50365d58b9048fb628f, https://github.com/facebook/react-native/commit/c71e6efbcd2b95faee327d9763d321488120bc5e).

My previous pull requests regarding iOS 11
* [Remove iOS 11 version check by ken0nek · Pull Request https://github.com/facebook/react-native/issues/32151 · facebook/react-native](https://github.com/facebook/react-native/pull/32151)
* [Remove iOS 11 availability check by ken0nek · Pull Request https://github.com/facebook/react-native/issues/32488 · facebook/react-native](https://github.com/facebook/react-native/pull/32488)
* [Remove iOS 11 deprecation warnings around SafeArea by ken0nek · Pull Request https://github.com/facebook/react-native/issues/32851 · facebook/react-native](https://github.com/facebook/react-native/pull/32851)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Changed] - Remove iOS 12 availability check

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

Reviewed By: NickGerleman

Differential Revision: D35021632

Pulled By: javache

fbshipit-source-id: bf85d44874a2c10cb345d33df7c9e4789312a7cd
2023-06-27 11:51:00 -07:00
Pieter De BaetsandFacebook GitHub Bot a855013fc6 Use static_cast instead of static_pointer_cast where possible (#37932)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37932

`static_cast<Derived &>(*sharedBase)` is preferred over `*std::static_pointer_cast<Derived>(sharedBase)`, since we don't need to copy the underlying shared_ptr to do so. The same applies for `std::const_pointer_cast`.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D46766558

fbshipit-source-id: 5d0b660107b2a60340952e2b5ec2792e3ed1832a
2023-06-16 08:00:57 -07:00
Fábio HenriquesandFacebook GitHub Bot 6b62f12ce9 Add smartInsertDelete prop to TextInput component (#36111)
Summary:
This PR add support to configure the `smartInsertDeleteType` property in iOS inputs [as described here](https://developer.apple.com/documentation/uikit/uitextinputtraits/2865828-smartinsertdeletetype), making possible toggle this autoformatting behavior.

PR for the docs update: https://github.com/facebook/react-native-website/pull/3560

## Changelog:

[IOS] [ADDED] - Add `smartInsertDelete` prop to `TextInput` component

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

Test Plan:
* Added an example in the RNTester app to test this behavior in iOS.
* If the `smartInsertDelete` prop is `true` or `undefined`, the system will use the default autoformatting behavior.
* If the `smartInsertDelete` prop is `false`, the system will disable the autoformatting behavior.

https://user-images.githubusercontent.com/20051562/217862828-70c20344-d687-4824-8f5d-d591eff856ef.mp4

Reviewed By: javache

Differential Revision: D46546277

Pulled By: NickGerleman

fbshipit-source-id: 3172b14fb196876d9ee0030186540608204b96de
2023-06-08 12:06:15 -07:00
Riccardo CipolleschiandFacebook GitHub Bot 610b14e4f3 Move min ios version to 13.4 for OSS (#36795)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36795

This change bump the min iOS version for React Native to 13.4, to align with company guidelines.

## Changelog:
[iOS][Changed] - Moved the min iOS version to 13.4

Reviewed By: cortinico

Differential Revision: D44634663

fbshipit-source-id: 035e8fcbb395f7394f8253e3ec485ad9937531c2
2023-04-06 12:07:26 -07:00
Ruslan ShestopalyukandFacebook GitHub Bot b9c64f3651 Bulk detect/correct (most of the) typos and misspells in RN core code
Summary:
## Changelog:
[Internal] -

While merging a Contributor PR in D43816768, I got curious whether such things as detecting/fixing typos could be automated.

There is a tool called [typos](https://github.com/crate-ci/typos), which, as it turns out, works very well on source code files.

The amount of false positives was minimal, most of the suggestions were valid ones.

And the total amount of typos found and fixed was **more than 300**, which is... quite a bit :)

### Methodology

* Run `typos` separately on `ReactCommon`, `Libraries`, `React`, `ReactAndroid` and `scripts` folders inside `packages/react-native`, e.g.:
```
$ typos -w --config ~/tmp/_typos.toml ~/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid
```

Contents of the `_typos.toml` config file:
```
[default.extend-words]
collapsable = "collapsable"
NDK = "NDK"
inout = "inout"
```

(yeah, it really didn't like the "collapsable" word, for some reason ;))
* Inspect all the changes manually and revert false positives (as mentioned, their amount was minimal)

Note that most of the changes are inside things like comments and error messages, however there are a few among identifier name fixes (`typos` is actually quite smart at understanding naming conventions in code) - I kept the suggestions in cases that are local and not part of a public API. There are also misspelled file name changes in a couple of cases.

Reviewed By: NickGerleman

Differential Revision: D44172494

fbshipit-source-id: 86e27edbbb99e09135e3cdd5d7cea8ffeb8307f4
2023-03-20 02:05:38 -07:00
Ruslan LesiutinandFacebook GitHub Bot 714b502b0c | RN Monorepo | Migrate to package (#36434)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36434

Changelog: [Internal]

This is a squashed stack of 18 commits, starting from D43202126

allow-large-files

Reviewed By: cortinico

Differential Revision: D43977381

fbshipit-source-id: 0da552ddb85f2f61a0be0ef071915b35f3f8555c
2023-03-17 05:03:25 -07:00