Skip to content

Commit 80089d0

Browse files
committed
Fix composer font height being smaller on first render
For emojis only text.
1 parent 64ed6a5 commit 80089d0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/components/Composer/implementation/index.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {isMobileSafari, isSafari} from '@libs/Browser';
2020
import {containsOnlyEmojis} from '@libs/EmojiUtils';
2121
import {base64ToFile} from '@libs/fileDownload/FileUtils';
2222
import isEnterWhileComposition from '@libs/KeyboardShortcut/isEnterWhileComposition';
23-
import variables from '@styles/variables';
2423
import CONST from '@src/CONST';
2524

2625
const excludeNoStyles: Array<keyof MarkdownStyle> = [];
@@ -73,7 +72,6 @@ function Composer(
7372
start: selectionProp.start,
7473
end: selectionProp.end,
7574
});
76-
const [hasMultipleLines, setHasMultipleLines] = useState(false);
7775
const [isRendered, setIsRendered] = useState(false);
7876

7977
// On mobile safari, the cursor will move from right to left with inputMode set to none during report transition
@@ -349,15 +347,15 @@ function Composer(
349347
const inputStyleMemo = useMemo(
350348
() => [
351349
StyleSheet.flatten([style, {outline: 'none'}]),
352-
StyleUtils.getComposeTextAreaPadding(isComposerFullSize),
350+
StyleUtils.getComposeTextAreaPadding(isComposerFullSize, textContainsOnlyEmojis),
353351
isMobileSafari() || isSafari() ? styles.rtlTextRenderForSafari : {},
354352
scrollStyleMemo,
355353
StyleUtils.getComposerMaxHeightStyle(maxLines, isComposerFullSize),
356354
isComposerFullSize ? {height: '100%', maxHeight: 'none'} : undefined,
357-
textContainsOnlyEmojis && hasMultipleLines ? styles.onlyEmojisTextLineHeight : {},
355+
textContainsOnlyEmojis ? styles.onlyEmojisTextLineHeight : {},
358356
],
359357

360-
[style, styles.rtlTextRenderForSafari, styles.onlyEmojisTextLineHeight, scrollStyleMemo, hasMultipleLines, StyleUtils, maxLines, isComposerFullSize, textContainsOnlyEmojis],
358+
[style, styles.rtlTextRenderForSafari, styles.onlyEmojisTextLineHeight, scrollStyleMemo, StyleUtils, maxLines, isComposerFullSize, textContainsOnlyEmojis],
361359
);
362360

363361
return (
@@ -379,7 +377,6 @@ function Composer(
379377
onSelectionChange={addCursorPositionToSelectionChange}
380378
onContentSizeChange={(e) => {
381379
setPrevHeight(e.nativeEvent.contentSize.height);
382-
setHasMultipleLines(e.nativeEvent.contentSize.height > variables.componentSizeLarge);
383380
}}
384381
disabled={isDisabled}
385382
onKeyPress={handleKeyPress}

src/styles/utils/index.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -953,18 +953,21 @@ function getEmojiPickerListHeight(isRenderingShortcutRow: boolean, windowHeight:
953953
}
954954

955955
/**
956-
* Returns padding vertical based on number of lines
956+
* Returns vertical padding based on number of lines.
957957
*/
958-
function getComposeTextAreaPadding(isComposerFullSize: boolean): TextStyle {
959-
let paddingValue = 5;
958+
function getComposeTextAreaPadding(isComposerFullSize: boolean, textContainsOnlyEmojis: boolean): TextStyle {
959+
let paddingTop = 8;
960+
let paddingBottom = 8;
960961
// Issue #26222: If isComposerFullSize paddingValue will always be 5 to prevent padding jumps when adding multiple lines.
961962
if (!isComposerFullSize) {
962-
paddingValue = 8;
963+
paddingTop = 8;
964+
paddingBottom = 8;
963965
}
964-
return {
965-
paddingTop: paddingValue,
966-
paddingBottom: paddingValue,
967-
};
966+
// We need to reduce the top padding because emojis have a bigger font height.
967+
if (textContainsOnlyEmojis) {
968+
paddingTop = 3;
969+
}
970+
return {paddingTop, paddingBottom};
968971
}
969972

970973
/**

0 commit comments

Comments
 (0)