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

Update composer number of lines when window width changes #29845

Merged
Merged
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: 4 additions & 5 deletions src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import RNTextInput from '@components/RNTextInput';
import Text from '@components/Text';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withNavigation from '@components/withNavigation';
import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as Browser from '@libs/Browser';
import compose from '@libs/compose';
import * as ComposerUtils from '@libs/ComposerUtils';
Expand Down Expand Up @@ -88,8 +88,6 @@ const propTypes = {
isComposerFullSize: PropTypes.bool,

...withLocalizePropTypes,

...windowDimensionsPropTypes,
};

const defaultProps = {
Expand Down Expand Up @@ -171,6 +169,7 @@ function Composer({
isComposerFullSize,
...props
}) {
const {windowWidth} = useWindowDimensions();
const textRef = useRef(null);
const textInput = useRef(null);
const initialValue = defaultValue ? `${defaultValue}` : `${value || ''}`;
Expand Down Expand Up @@ -368,7 +367,7 @@ function Composer({
setNumberOfLines(generalNumberOfLines);
textInput.current.style.height = 'auto';
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value, maxLines, numberOfLinesProp, onNumberOfLinesChange, isFullComposerAvailable, setIsFullComposerAvailable]);
}, [value, maxLines, numberOfLinesProp, onNumberOfLinesChange, isFullComposerAvailable, setIsFullComposerAvailable, windowWidth]);

useEffect(() => {
updateNumberOfLines();
Expand Down Expand Up @@ -502,4 +501,4 @@ const ComposerWithRef = React.forwardRef((props, ref) => (

ComposerWithRef.displayName = 'ComposerWithRef';

export default compose(withLocalize, withWindowDimensions, withNavigation)(ComposerWithRef);
export default compose(withLocalize, withNavigation)(ComposerWithRef);
Loading