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: auto focus and scroll to bottom on large-text in composer #28790

Merged
merged 15 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
7 changes: 5 additions & 2 deletions src/libs/UpdateMultilineInputRange/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
* See https://github.com/Expensify/App/issues/20836 for more details.
*
* @param {Object} input the input element
* @param {boolean} shouldAutoFocus
*/
export default function updateMultilineInputRange(input) {
export default function updateMultilineInputRange(input, shouldAutoFocus = true) {
if (!input) {
return;
}
Expand All @@ -19,5 +20,7 @@ export default function updateMultilineInputRange(input) {
* Issue: does not scroll multiline input when text exceeds the maximum number of lines
* For more details: https://github.com/Expensify/App/pull/27702#issuecomment-1728651132
*/
input.focus();
if (shouldAutoFocus) {
input.focus();
}
}
4 changes: 3 additions & 1 deletion src/libs/UpdateMultilineInputRange/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
* See https://github.com/Expensify/App/issues/20836 for more details.
*
* @param {Object} input the input element
* @param {boolean} shouldAutoFocus
*/
export default function updateMultilineInputRange(input) {
// eslint-disable-next-line no-unused-vars
export default function updateMultilineInputRange(input, shouldAutoFocus = true) {
if (!input) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import withKeyboardState from '../../../../components/withKeyboardState';
import {propTypes, defaultProps} from './composerWithSuggestionsProps';
import focusWithDelay from '../../../../libs/focusWithDelay';
import useDebounce from '../../../../hooks/useDebounce';
import updateMultilineInputRange from '../../../../libs/UpdateMultilineInputRange';

const {RNTextInputReset} = NativeModules;

Expand Down Expand Up @@ -490,9 +491,13 @@ function ComposerWithSuggestions({
}, [focus, prevIsFocused, prevIsModalVisible, isFocused, modal.isVisible, isNextModalWillOpenRef]);

useEffect(() => {
// Set the `selection at end` and `scrolls input to bottom` for `Web Platforms`.
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
updateMultilineInputRange(textInputRef.current, shouldAutoFocus);

if (value.length === 0) {
return;
}

Report.setReportWithDraft(reportID, true);

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Loading