Skip to content

iOS: reload input views when autoCapitalize/autoCorrect/spellCheck change on a focused TextInput (Fabric) - #60319

Merged
cipolleschi merged 1 commit into
react:mainfrom
rarya618:ios-textinput-reload-traits
Nov 27, 2026
Merged

cipolleschi merged 1 commit into
react:mainfrom
rarya618:ios-textinput-reload-traits

Conversation

@rarya618

Copy link
Copy Markdown
Contributor

Summary:

On iOS with the New Architecture, changing autoCapitalize, autoCorrect or spellCheck on a TextInput that is focused updates the backing UITextView/UITextField, but the keyboard keeps its old settings until the input loses and regains focus. UIKit only re-reads text input traits for the first responder when reloadInputViews is called.

RCTTextInputComponentView already calls reloadInputViews when keyboardType or returnKeyType change on a focused input (#57868). This does the same for autocapitalization, autocorrection and spell checking. When several of them change in one props update, which is common when an app switches an input between modes, the keyboard reloads once, not once for each.

A real case: a screenwriting editor switches a line between dialogue (sentence case, autocorrect on) and a character cue (capitals, autocorrect off) while the writer types. Without this change, the keyboard stays in sentence case on the cue until the writer leaves the line.

Changelog:

[IOS] [FIXED] - A focused TextInput's keyboard now follows changes to autoCapitalize, autoCorrect and spellCheck without losing focus

Test Plan:

Repro (below): a multiline TextInput with buttons outside any ScrollView that toggle autoCapitalize between sentences and characters, and toggle autoCorrect and spellCheck. The device needs Settings › General › Keyboard › Auto-Capitalization on, because with it off iOS ignores autoCapitalize entirely.

  • Before (same device and build, without this change): with the input focused, switching autoCapitalize, autoCorrect or spellCheck doesn't reach the keyboard. It keeps its old settings until you tap out of the input and back in.
  • After: the keyboard switches to capitals right away and back again, with no dismiss or bounce. The caret stays where it was.
  • Tested on an iPhone with React Native 0.88.1 (Fabric) in an Expo SDK 58 development build with React Native compiled from source and this change applied as a patch. In the repro, each prop changed alone reached the focused keyboard in place: autoCapitalize (type a word, switch to characters, and Shift comes back on), autoCorrect (turned off, "teh" is no longer corrected) and spellCheck (turned off, new misspellings aren't underlined). In an app that switches all three at once on a focused multiline input, the keyboard reloads once and doesn't dismiss.
Repro.tsx
// Repro: on iOS (Fabric), changing autoCapitalize, autoCorrect or spellCheck on a
// TextInput that is focused doesn't reach the keyboard until the input loses and
// regains focus. Device setting needed: Settings › General › Keyboard ›
// Auto-Capitalization on (with it off, iOS ignores autoCapitalize entirely).
//
// 1. Tap into the input. The keyboard opens in sentence case (Shift on for the first letter).
// 2. Tap "Capitals: off" so it reads "Capitals: on" (the input keeps focus; the
//    buttons sit outside any ScrollView).
//    Expected: the keyboard switches to capitals at once.
//    Actual: it stays in sentence case until you tap out of the input and back in.
// 3. The same goes for "Autocorrect" and "Spell check".

import { useState } from "react";
import { Pressable, StyleSheet, Text, TextInput, View } from "react-native";

export default function App() {
  const [capitals, setCapitals] = useState(false);
  const [autoCorrect, setAutoCorrect] = useState(true);
  const [spellCheck, setSpellCheck] = useState(true);

  return (
    <View style={styles.screen}>
      <TextInput
        multiline
        autoFocus
        autoCapitalize={capitals ? "characters" : "sentences"}
        autoCorrect={autoCorrect}
        spellCheck={spellCheck}
        placeholder="Type here"
        style={styles.input}
      />
      <View style={styles.row}>
        <Toggle label="Capitals" on={capitals} onPress={() => setCapitals(value => !value)} />
        <Toggle label="Autocorrect" on={autoCorrect} onPress={() => setAutoCorrect(value => !value)} />
        <Toggle label="Spell check" on={spellCheck} onPress={() => setSpellCheck(value => !value)} />
      </View>
    </View>
  );
}

function Toggle({label, on, onPress}: {label: string, on: boolean, onPress: () => void}) {
  return (
    <Pressable onPress={onPress} style={styles.toggle}>
      <Text>{label}: {on ? "on" : "off"}</Text>
    </Pressable>
  );
}

const styles = StyleSheet.create({
  screen: {flex: 1, paddingTop: 80, paddingHorizontal: 20, gap: 16},
  input: {fontSize: 18, minHeight: 80, borderWidth: 1, borderColor: "#ccc", borderRadius: 8, padding: 12},
  row: {flexDirection: "row", gap: 8, flexWrap: "wrap"},
  toggle: {padding: 10, borderWidth: 1, borderColor: "#ccc", borderRadius: 8},
});

…ange on a focused TextInput

On iOS (Fabric), changing autoCapitalize, autoCorrect or spellCheck on a focused
TextInput updated the backing view but not the keyboard, which kept its old
settings until the input lost and regained focus. Call reloadInputViews when
any of them change on the first responder, as is already done for keyboardType
and returnKeyType, once per props update when several change together.
@meta-cla

meta-cla Bot commented Nov 26, 2026

Copy link
Copy Markdown

Hi @rarya618!

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!

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 26, 2026
@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 Nov 26, 2026
@meta-cla

meta-cla Bot commented Nov 26, 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 Nov 26, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at b3e7a62b9f50.

android: no capture

@cipolleschi
cipolleschi merged commit ce56c6c into react:main Nov 27, 2026
90 checks passed
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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. 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.

2 participants