Skip to content

Commit

Permalink
Merge pull request Expensify#26926 from jscardona12/hotfix/26222
Browse files Browse the repository at this point in the history
26222: Fix padding jump when isComposerFullSize
  • Loading branch information
deetergp authored Sep 9, 2023
2 parents 5c13816 + e703657 commit b11bddc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -111,6 +114,7 @@ const defaultProps = {
shouldCalculateCaretPosition: false,
checkComposerVisibility: () => false,
isReportActionCompose: false,
isComposerFullSize: false,
};

/**
Expand Down Expand Up @@ -161,6 +165,7 @@ function Composer({
checkComposerVisibility,
selection: selectionProp,
isReportActionCompose,
isComposerFullSize,
...props
}) {
const textRef = useRef(null);
Expand Down Expand Up @@ -440,9 +445,9 @@ function Composer({
numberOfLines < maxLines ? styles.overflowHidden : {},

StyleSheet.flatten([style, {outline: 'none'}]),
StyleUtils.getComposeTextAreaPadding(numberOfLinesProp),
StyleUtils.getComposeTextAreaPadding(numberOfLinesProp, isComposerFullSize),
],
[style, maxLines, numberOfLinesProp, numberOfLines],
[style, maxLines, numberOfLinesProp, numberOfLines, isComposerFullSize],
);

return (
Expand Down
15 changes: 11 additions & 4 deletions src/styles/StyleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
// Issue #26222: If isComposerFullSize paddingValue will always be 5 to prevent padding jumps when adding multiple lines.
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,
Expand Down

0 comments on commit b11bddc

Please sign in to comment.