Repository navigation
Fix empty input accessory button on TextInput without inputAccessoryViewButtonLabel - #59095
jkasprzyk17 wants to merge 1 commit into
Conversation
…iewButtonLabel An unset inputAccessoryViewButtonLabel reaches RCTTextInputComponentView as an empty string and was applied as @"", which setDefaultInputAccessoryView treats as a label. A number-pad TextInput reusing a recycled view that had a label, or whose label was removed, showed a toolbar with an empty button instead of no toolbar or the returnKeyType title. Map an empty label to nil, as the old architecture did. Fixes react#58952
|
Hi @jkasprzyk17! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
Fixes #58952.
With the new architecture, a number-pad
TextInputwithoutinputAccessoryViewButtonLabelcan show a toolbar with an empty button above the keyboard.An unset
inputAccessoryViewButtonLabelreachesRCTTextInputComponentViewas an emptystd::string.RCTNSStringFromString("")returns@"", notnil, andsetDefaultInputAccessoryViewtreats any non-nil label as set. The empty string is applied whenever the label goes from set to unset:_propsstill holds the props of the input the view was recycled from. A new input without a label then diffs"Next"→""and gets@"". BecauseprepareForRecyclereset_hasInputAccessoryView, a toolbar with an empty button is created.@"", and the toolbar keeps the old title.This change maps an empty label to
nilwith the existingRCTNSStringFromStringNilIfEmptyhelper. This matches the old architecture, where the label was anNSStringview property and an unset label wasnil. The issue suggests clearing the label inprepareForRecycle, but that isn't enough on its own: the diff against the stale_propswould still assign@"".Changelog:
[IOS] [FIXED] - Fix empty input accessory toolbar on a number-pad
TextInputwithoutinputAccessoryViewButtonLabelTest Plan:
Added
RCTTextInputComponentViewTestswith four cases:returnKeyTypetitleReact/Testsisn't compiled by any open source target, so I couldn't run these tests locally. I did check that the file compiles (-fsyntax-only) with the same clang flags the RNTester build uses forRCTTextInputComponentView.mm.I tested manually in RNTester (Debug, new architecture, iPhone 17 Pro simulator, iOS 26.5) with this Playground code:
RNTesterPlayground.js
Steps: tap "Swap to unlabelled", then focus the unlabelled input. The new input reuses the recycled view of the labelled one.
Before: a toolbar with an empty button above the number pad. After: no toolbar. The labelled input still shows "Next". I also removed the label from a focused number-pad input: the toolbar now goes away.
Commands: