From 60637fea3bf5b51d7696beab57e1f752387a15ed Mon Sep 17 00:00:00 2001 From: u9g Date: Fri, 25 Sep 2026 03:58:42 -0400 Subject: [PATCH] [fix] TextInput multiline defaults to 1 row The docs state that 'rows' defaults to 1, and it did until the prop fallback refactor in 76383017 dropped the final default. Since then a multiline TextInput without 'rows' or 'numberOfLines' renders a textarea with no 'rows' attribute, so browsers apply their default of 2 rows. --- .../src/exports/TextInput/__tests__/index-test.js | 6 ++++++ packages/react-native-web/src/exports/TextInput/index.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js b/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js index acbe26be1b..ad4f543251 100644 --- a/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js +++ b/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js @@ -306,6 +306,12 @@ describe('components/TextInput', () => { const textarea = findTextArea(container); expect(textarea.getAttribute('rows')).toEqual('3'); }); + + test('with "multiline" defaults to 1 row', () => { + const { container } = render(); + const textarea = findTextArea(container); + expect(textarea.getAttribute('rows')).toEqual('1'); + }); }); test('prop "onBlur"', () => { diff --git a/packages/react-native-web/src/exports/TextInput/index.js b/packages/react-native-web/src/exports/TextInput/index.js index 8f8de0bf0f..b8152e3409 100644 --- a/packages/react-native-web/src/exports/TextInput/index.js +++ b/packages/react-native-web/src/exports/TextInput/index.js @@ -420,7 +420,7 @@ const TextInput: React.AbstractComponent< ); } */ - supportedProps.rows = multiline ? (rows != null ? rows : numberOfLines) : 1; + supportedProps.rows = multiline ? rows ?? numberOfLines ?? 1 : 1; supportedProps.spellCheck = spellCheck != null ? spellCheck : autoCorrect; supportedProps.style = [ { '--placeholderTextColor': placeholderTextColor },