Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On iOS (Fabric), a
TextInputplaceholder can keep theletterSpacingof a style it no longer has.UIKit behaviour behind it: once a
UITextFieldhas shown a new placeholder string withNSKernAttributeName, it keeps drawing that kerning for later placeholders that carry no kern attribute (settingattributedPlaceholdertonil, orsetNeedsDisplay, does not reset it; an explicitNSKernAttributeNamevalue or a new text field does). React Native only addsNSKernAttributeNamewhenletterSpacingis set (RCTAttributedTextUtils.mm), so removingletterSpacingcannot undo it.Two ways an app gets there:
TextInputwithletterSpacingunmounts and its component view is reused for aTextInputwithout it and with a different placeholder._propsstill holds the previous component's props, andupdatePropssets the new placeholder before the new text attributes, so the new string first reaches UIKit with the old kerning — and keeps it. Example: a one-time code field withletterSpacingfollowed by a search field shows its placeholder asS e a r c h.letterSpacingis set, thenletterSpacingis removed.Setting
letterSpacing: 0works around it, but it is not equivalent to leaving it unset:NSKernAttributeName: 0disables the font's pair kerning.The fix, in
RCTTextInputComponentView:textAttributesbeforeplaceholderinupdateProps, so a new placeholder string never reaches UIKit with stale attributes;letterSpacinggoes from set to unset on a single-line input with no text, recreate the backed text input (the existing_setMultiline:path, which copies its configuration), restoring focus if it had it. An input that holds text is left alone, since its placeholder is hidden. Multiline inputs are not recreated:RCTUITextViewdraws its own placeholder label and does not show the bug.Changelog:
[IOS] [FIXED] - TextInput placeholder no longer keeps a removed
letterSpacing, including after view recyclingTest Plan:
RNTester built from source (
main@ 225e8aa), iPhone 17 Pro simulator, iOS 26.0, New Architecture. Repro:letterSpacing: 6.8input new input without it, other placeholderS e a r c hSearchletterSpacing: 6.8, then it is removedS e a r c hSearchSearchSearchletterSpacingset again after removalSearch(not affected)SearchSearch(not affected)SearchBefore / after (same Playground, same steps, only the native build differs):
Unrelated, seen on
mainwith and without this change: addingletterSpacingto an uncontrolled multilineTextInputthat holds text clears the text.