Skip to content

Preserve TextInput returnKeyType when changing multiline - #58355

Open
jamfromouterspace wants to merge 1 commit into
react:mainfrom
jamfromouterspace:fix-textinput-returnkeytype
Open

Preserve TextInput returnKeyType when changing multiline#58355
jamfromouterspace wants to merge 1 commit into
react:mainfrom
jamfromouterspace:fix-textinput-returnkeytype

Conversation

@jamfromouterspace

@jamfromouterspace jamfromouterspace commented Sep 5, 2026

Copy link
Copy Markdown

Summary:

RCTCopyBackedTextInput is called when a TextInput switches between
single-line and multiline and the Fabric component view swaps its backing
UIKit view (RCTUITextField <-> RCTUITextView). It copies the keyboard
traits across to the replacement view, but returnKeyType is not among them —
keyboardType is copied on the line directly above it.

Because the prop itself has not changed across the transition, the prop diff in
RCTTextInputComponentView sees done -> done and does not re-run the
setter. The replacement view therefore keeps its default Return key, so an
input declared returnKeyType="done" renders the newline key instead of Done
once it has flipped to multiline.

This is the same class of omission that was fixed for tintColor in #57748,
and the fix is the same shape: copy the property along with its neighbours.

Repro: a TextInput with a stable key and returnKeyType="done" whose
multiline prop goes false -> true. After the transition, focusing it shows
the default Return key. Fabric view recycling can produce the same backing-view
transition even for an input that is always multiline, which makes it
intermittent in real apps.

Verified against 0.86.3; the line is still missing on 0.87.1 and on main.

Changelog:

[IOS] [FIXED] - Preserve TextInput returnKeyType when switching between single-line and multiline backing views.

Test Plan:

Added testCopyBackedTextInputPreservesReturnKeyType to
React/Tests/Text/RCTTextInputUtilsTest.mm, alongside the existing
testCopyBackedTextInputPreservesTintColor added in #57748. It sets
returnKeyType = UIReturnKeyDone on an RCTUITextField, runs
RCTCopyBackedTextInput into an RCTUITextView, and asserts the value
survives. The test fails without the one-line change and passes with it.

Also confirmed in a production app: a multiline TextInput with
returnKeyType="done" intermittently displayed the newline key, and adding
this single line fixed it.

RCTCopyBackedTextInput copies the keyboard traits over to the replacement
backing view when a TextInput switches between single-line and multiline,
but omits returnKeyType. The prop itself is unchanged across the
transition, so the prop diff does not re-run the setter and the new view
keeps its default Return key.

Copy returnKeyType alongside keyboardType, and add a regression test next
to the existing tintColor one.
@meta-cla

meta-cla Bot commented Sep 5, 2026

Copy link
Copy Markdown

Hi @jamfromouterspace!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 5, 2026
@meta-cla

meta-cla Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant