From 562db69a0f3305b07f252ad26b4661bb92bcb72c Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 23 Aug 2021 19:39:48 +0000 Subject: [PATCH] [fix] numberOfLines=1 on Safari Safari requires use of `white-space:nowrap` if not using the multi-line technique. This patch uses the multi-lines styles to truncate single-lines. Fix #2111 Close #2113 --- .../Text/__tests__/__snapshots__/index-test.js.snap | 2 +- packages/react-native-web/src/exports/Text/index.js | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/react-native-web/src/exports/Text/__tests__/__snapshots__/index-test.js.snap b/packages/react-native-web/src/exports/Text/__tests__/__snapshots__/index-test.js.snap index d9790bb13..7c1a743be 100644 --- a/packages/react-native-web/src/exports/Text/__tests__/__snapshots__/index-test.js.snap +++ b/packages/react-native-web/src/exports/Text/__tests__/__snapshots__/index-test.js.snap @@ -159,7 +159,7 @@ exports[`components/Text prop "numberOfLines" value is set 1`] = ` exports[`components/Text prop "numberOfLines" value is set to one 1`] = `
`; diff --git a/packages/react-native-web/src/exports/Text/index.js b/packages/react-native-web/src/exports/Text/index.js index e87af4c95..a2a74ce47 100644 --- a/packages/react-native-web/src/exports/Text/index.js +++ b/packages/react-native-web/src/exports/Text/index.js @@ -73,12 +73,11 @@ const Text: React.AbstractComponent = const classList = [ classes.text, hasTextAncestor === true && classes.textHasAncestor, - numberOfLines === 1 && classes.textOneLine, - numberOfLines != null && numberOfLines > 1 && classes.textMultiLine + numberOfLines != null && classes.textMultiLine ]; const style = [ props.style, - numberOfLines != null && numberOfLines > 1 && { WebkitLineClamp: numberOfLines }, + numberOfLines != null && { WebkitLineClamp: numberOfLines }, selectable === true && styles.selectable, selectable === false && styles.notSelectable, onPress && styles.pressable @@ -180,12 +179,6 @@ const classes = css.create({ font: 'inherit', whiteSpace: 'inherit' }, - textOneLine: { - maxWidth: '100%', - overflow: 'hidden', - textOverflow: 'ellipsis', - whiteSpace: 'pre' - }, // See #13 textMultiLine: { display: '-webkit-box',