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

Fix/35368: Composer is not shrinked #35865

Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 4 additions & 1 deletion src/components/Composer/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Composer(
// user can read new chats without the keyboard in the way of the view.
// On Android the selection prop is required on the TextInput but this prop has issues on IOS
selection,
resetFullComposerSize = () => {},
...props
}: ComposerProps,
ref: ForwardedRef<TextInput>,
Expand Down Expand Up @@ -73,7 +74,9 @@ function Composer(
autoComplete="off"
placeholderTextColor={theme.placeholderText}
ref={setTextInputRef}
onContentSizeChange={(e) => ComposerUtils.updateNumberOfLines({maxLines, isComposerFullSize, isDisabled, setIsFullComposerAvailable}, e, styles)}
onContentSizeChange={(e) =>
ComposerUtils.updateNumberOfLines({maxLines, isComposerFullSize, isDisabled, setIsFullComposerAvailable, resetFullComposerSize, value: props.value}, e, styles)
}
rejectResponderTermination={false}
smartInsertDelete={false}
textAlignVertical="center"
Expand Down
5 changes: 5 additions & 0 deletions src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import updateIsFullComposerAvailable from '@libs/ComposerUtils/updateIsFullCompo
import * as FileUtils from '@libs/fileDownload/FileUtils';
import isEnterWhileComposition from '@libs/KeyboardShortcut/isEnterWhileComposition';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import type {ComposerProps} from './types';

Expand Down Expand Up @@ -70,6 +71,7 @@ function Composer(
start: 0,
end: 0,
},
resetFullComposerSize = () => {},
isReportActionCompose = false,
isComposerFullSize = false,
shouldContainScroll = false,
Expand Down Expand Up @@ -248,6 +250,9 @@ function Composer(
onNumberOfLinesChange(generalNumberOfLines);
updateIsFullComposerAvailable({isFullComposerAvailable, setIsFullComposerAvailable}, generalNumberOfLines);
setNumberOfLines(generalNumberOfLines);
if (generalNumberOfLines === 1 && ReportUtils.getCommentLength(value ?? '') === 0) {
resetFullComposerSize();
}
textInput.current.style.height = 'auto';
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value, maxLines, numberOfLinesProp, onNumberOfLinesChange, isFullComposerAvailable, setIsFullComposerAvailable, windowWidth]);
Expand Down
3 changes: 3 additions & 0 deletions src/components/Composer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type ComposerProps = {

onBlur?: (event: NativeSyntheticEvent<TextInputFocusEventData>) => void;

/** Function to reset the full composer size */
resetFullComposerSize?: () => void;

/** Should make the input only scroll inside the element avoid scroll out to parent */
shouldContainScroll?: boolean;
};
Expand Down
4 changes: 4 additions & 0 deletions src/libs/ComposerUtils/updateNumberOfLines/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import getNumberOfLines from '@libs/ComposerUtils/getNumberOfLines';
import updateIsFullComposerAvailable from '@libs/ComposerUtils/updateIsFullComposerAvailable';
import * as ReportUtils from '@libs/ReportUtils';

Check failure on line 3 in src/libs/ComposerUtils/updateNumberOfLines/index.native.ts

View workflow job for this annotation

GitHub Actions / lint

'ReportUtils' is defined but never used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to remove this.

import type UpdateNumberOfLines from './types';

/**
Expand All @@ -14,6 +15,9 @@
return;
}
const numberOfLines = getNumberOfLines(lineHeight, paddingTopAndBottom, inputHeight);
if (numberOfLines === 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove ReportUtils.getCommentLength(value ?? '') === 0?

props.resetFullComposerSize?.();
}
updateIsFullComposerAvailable(props, numberOfLines);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function ComposerWithSuggestions({
listHeight,
isScrollLikelyLayoutTriggered,
raiseIsScrollLikelyLayoutTriggered,
resetFullComposerSize,
// Refs
suggestionsRef,
animatedRef,
Expand Down Expand Up @@ -624,6 +625,7 @@ function ComposerWithSuggestions({
onLayout={onLayout}
onScroll={hideSuggestionMenu}
shouldContainScroll={Browser.isMobileSafari()}
resetFullComposerSize={resetFullComposerSize}
/>
</View>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function ReportActionCompose({
measureParentContainer={measureContainer}
listHeight={listHeight}
onValueChange={validateCommentMaxLength}
resetFullComposerSize={resetFullComposerSize}
/>
<ReportDropUI
onDrop={(e) => {
Expand Down
Loading