Description
Description
On macOS, a single-line TextInput that changes size while it's focused draws its text and placeholder at the top of the field until it loses focus. A search field that makes room for a Cancel button on focus is one case.
-[NSTextField setFrameSize:] resizes the field editor's clip view to the cell's drawing rect. That leaves out RCTUITextFieldCell's title rect: its padding (textContainerInset) and, since #3074, the vertical centering. In a 40pt field, the text jumps 10.5pt up.
setTextContainerInset: already relocates the field editor when the padding changes. A resize doesn't.
Steps to reproduce
- In RNTester's Playground (
packages/rn-tester/js/examples/Playground/RNTesterPlayground.js):function Playground() { const [focused, setFocused] = React.useState(false); return ( <View style={{padding: 10}}> <View style={{flexDirection: 'row', alignItems: 'center'}}> <TextInput placeholder="Search" onFocus={() => setFocused(true)} onBlur={() => setFocused(false)} style={{flex: 1, height: 40, borderWidth: 1}} /> {focused && <Text style={{marginLeft: 10}}>Cancel</Text>} </View> </View> ); }
- Open the Playground in
RNTester-macOSand click into the field.
Expected: the placeholder stays vertically centered. On main (8941740): it moves to the top of the field. The field editor's clip view goes from y 10.5 to y 0.
React Native Version
0.83.10, with react-native-macos 0.83.0. Also on main (8941740).
Affected Platforms
Runtime - MacOS
Output of npx @react-native-community/cli info
OS: macOS 26.6.2 (25G83), Apple M3
Xcode 27.1 (27A9275), macOS SDK 27.0
Node 24.19.0, CocoaPods 1.17.0
react-native 0.83.10, react-native-macos 0.83.0, new architecture
Stacktrace or Logs
No crash; the text is drawn in the wrong place.
Reproducer
The Playground change in step 1, against main. A PR with a fix follows.
Activity