Skip to content

Commit 48520ec

Browse files
authored
Merge pull request #55438 from CyberAndrii/55068-fix-composer-font-height-being-smaller-on-first-render
Fix composer font height being smaller on first render
2 parents 1652004 + 403d658 commit 48520ec

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/components/Composer/implementation/index.tsx

Lines changed: 3 additions & 6 deletions
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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -955,18 +955,21 @@ function getEmojiPickerListHeight(isRenderingShortcutRow: boolean, windowHeight:
955955
}
956956

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

972975
/**

0 commit comments

Comments
 (0)