From e07ca844145715c070e2e61f2ec35efe64e6d3f4 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Cardona Date: Wed, 6 Sep 2023 23:39:39 -0500 Subject: [PATCH 1/3] 26222: Fix padding jump when isComposerFullSize --- src/components/Composer/index.js | 3 ++- src/styles/StyleUtils.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index cbd22cc39dfd..e136c18f897b 100755 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -161,6 +161,7 @@ function Composer({ checkComposerVisibility, selection: selectionProp, isReportActionCompose, + isComposerFullSize, ...props }) { const textRef = useRef(null); @@ -440,7 +441,7 @@ function Composer({ numberOfLines < maxLines ? styles.overflowHidden : {}, StyleSheet.flatten([style, {outline: 'none'}]), - StyleUtils.getComposeTextAreaPadding(numberOfLinesProp), + StyleUtils.getComposeTextAreaPadding(numberOfLinesProp, isComposerFullSize), ], [style, maxLines, numberOfLinesProp, numberOfLines], ); diff --git a/src/styles/StyleUtils.ts b/src/styles/StyleUtils.ts index 1def6de70819..464afdac87e6 100644 --- a/src/styles/StyleUtils.ts +++ b/src/styles/StyleUtils.ts @@ -1098,11 +1098,18 @@ function getMentionTextColor(isOurMention: boolean): string { /** * Returns padding vertical based on number of lines */ -function getComposeTextAreaPadding(numberOfLines: number): ViewStyle | CSSProperties { +function getComposeTextAreaPadding(numberOfLines: number, isComposerFullSize: boolean): ViewStyle | CSSProperties { let paddingValue = 5; - if (numberOfLines === 1) paddingValue = 9; - // In case numberOfLines = 3, there will be a Expand Icon appearing at the top left, so it has to be recalculated so that the textArea can be full height - if (numberOfLines === 3) paddingValue = 8; + // If isComposerFullSize paddingValue will always be 5 + if (!isComposerFullSize) { + if (numberOfLines === 1) { + paddingValue = 9; + } + // In case numberOfLines = 3, there will be a Expand Icon appearing at the top left, so it has to be recalculated so that the textArea can be full height + else if (numberOfLines === 3) { + paddingValue = 8; + } + } return { paddingTop: paddingValue, paddingBottom: paddingValue, From b9b00727ae0457bcc90e473c52b80c74de7daa11 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Cardona Date: Thu, 7 Sep 2023 02:13:32 -0500 Subject: [PATCH 2/3] Add isComposerFullSize to Memo Dependency --- src/components/Composer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index e136c18f897b..eca68aa345b6 100755 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -443,7 +443,7 @@ function Composer({ StyleSheet.flatten([style, {outline: 'none'}]), StyleUtils.getComposeTextAreaPadding(numberOfLinesProp, isComposerFullSize), ], - [style, maxLines, numberOfLinesProp, numberOfLines], + [style, maxLines, numberOfLinesProp, numberOfLines, isComposerFullSize], ); return ( From e7036571575e41144cf7e6e86fd1d96746607bd7 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Cardona Date: Fri, 8 Sep 2023 08:31:38 -0500 Subject: [PATCH 3/3] Add isComposerFullSize to PropTypes and defaultProps Signed-off-by: Juan Sebastian Cardona --- src/components/Composer/index.js | 4 ++++ src/styles/StyleUtils.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index eca68aa345b6..d29e89452e30 100755 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -83,6 +83,9 @@ const propTypes = { /** Whether this is the report action compose */ isReportActionCompose: PropTypes.bool, + /** Whether the sull composer is open */ + isComposerFullSize: PropTypes.bool, + ...withLocalizePropTypes, ...windowDimensionsPropTypes, @@ -111,6 +114,7 @@ const defaultProps = { shouldCalculateCaretPosition: false, checkComposerVisibility: () => false, isReportActionCompose: false, + isComposerFullSize: false, }; /** diff --git a/src/styles/StyleUtils.ts b/src/styles/StyleUtils.ts index 464afdac87e6..6e26056e2050 100644 --- a/src/styles/StyleUtils.ts +++ b/src/styles/StyleUtils.ts @@ -1100,7 +1100,7 @@ function getMentionTextColor(isOurMention: boolean): string { */ function getComposeTextAreaPadding(numberOfLines: number, isComposerFullSize: boolean): ViewStyle | CSSProperties { let paddingValue = 5; - // If isComposerFullSize paddingValue will always be 5 + // Issue #26222: If isComposerFullSize paddingValue will always be 5 to prevent padding jumps when adding multiple lines. if (!isComposerFullSize) { if (numberOfLines === 1) { paddingValue = 9;