Skip to content

Commit

Permalink
use focusAndUpdateMultilineInputRange for auto-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
techievivek committed Sep 15, 2023
1 parent 9cfa85f commit 4b29f85
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/pages/PrivateNotes/PrivateNotesEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import personalDetailsPropType from '../personalDetailsPropType';
import * as Report from '../../libs/actions/Report';
import useLocalize from '../../hooks/useLocalize';
import OfflineWithFeedback from '../../components/OfflineWithFeedback';
import focusAndUpdateMultilineInputRange from '../../libs/focusAndUpdateMultilineInputRange';

const propTypes = {
/** All of the personal details for everyone */
Expand Down Expand Up @@ -77,19 +78,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => {
if (!privateNotesInput.current) {
return;
}

privateNotesInput.current.focus();

// Below condition is needed for web, desktop and mweb only, for native cursor to position at end by default.
if (privateNotesInput.current.value && privateNotesInput.current.setSelectionRange) {
const length = privateNotesInput.current.value.length;
privateNotesInput.current.setSelectionRange(length, length);
}
}}
onEntryTransitionEnd={() => focusAndUpdateMultilineInputRange(privateNotesInput.current)}
>
<FullPageNotFoundView
shouldShow={_.isEmpty(report) || _.isEmpty(report.privateNotes) || !_.has(report, ['privateNotes', route.params.accountID, 'note']) || !isCurrentUserNote}
Expand Down

0 comments on commit 4b29f85

Please sign in to comment.