Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26222: Fix padding jump when isComposerFullSize #26926

Merged
merged 3 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
jscardona12 marked this conversation as resolved.
Show resolved Hide resolved
...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
Loading