Skip to content

Commit

Permalink
Merge pull request #27220 from b4s36t4/fix/assignee-transition
Browse files Browse the repository at this point in the history
fix transition for task assignee modals
  • Loading branch information
yuwenmemon authored Sep 19, 2023
2 parents 436b75d + eb49e92 commit ae30313
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/pages/tasks/TaskAssigneeSelectorModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable es/no-optional-chaining */
import React, {useState, useEffect, useMemo, useCallback} from 'react';
import React, {useState, useEffect, useMemo, useCallback, useRef} from 'react';
import {View} from 'react-native';
import lodashGet from 'lodash/get';
import _ from 'underscore';
Expand Down Expand Up @@ -80,6 +80,8 @@ function TaskAssigneeSelectorModal(props) {
const [filteredCurrentUserOption, setFilteredCurrentUserOption] = useState(null);
const [isLoading, setIsLoading] = React.useState(true);

const optionRef = useRef();

const updateOptions = useCallback(() => {
const {recentReports, personalDetails, userToInvite, currentUserOption} = OptionsListUtils.getNewChatOptions(
props.reports,
Expand Down Expand Up @@ -201,7 +203,10 @@ function TaskAssigneeSelectorModal(props) {
const isTaskNonEditable = report && ReportUtils.isTaskReport(props.task.report) && (!canModifyTask || !isOpen);

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => optionRef.current && optionRef.current.textInput.focus()}
>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView shouldShow={isTaskNonEditable}>
<HeaderWithBackButton
Expand All @@ -219,6 +224,8 @@ function TaskAssigneeSelectorModal(props) {
shouldShowOptions={didScreenTransitionEnd && !isLoading}
textInputLabel={props.translate('optionsSelector.nameEmailOrPhoneNumber')}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
autoFocus={false}
ref={optionRef}
/>
</View>
</FullPageNotFoundView>
Expand Down
11 changes: 9 additions & 2 deletions src/pages/tasks/TaskShareDestinationSelectorModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable es/no-optional-chaining */
import React, {useState, useEffect, useMemo, useCallback} from 'react';
import React, {useState, useEffect, useMemo, useCallback, useRef} from 'react';
import _ from 'underscore';
import {View} from 'react-native';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -46,6 +46,8 @@ function TaskShareDestinationSelectorModal(props) {
const [headerMessage, setHeaderMessage] = useState('');
const [filteredRecentReports, setFilteredRecentReports] = useState([]);

const optionRef = useRef();

const filteredReports = useMemo(() => {
const reports = {};
_.keys(props.reports).forEach((reportKey) => {
Expand Down Expand Up @@ -111,7 +113,10 @@ function TaskShareDestinationSelectorModal(props) {

const sections = getSections();
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => optionRef.current && optionRef.current.textInput.focus()}
>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<HeaderWithBackButton
Expand All @@ -131,6 +136,8 @@ function TaskShareDestinationSelectorModal(props) {
shouldShowOptions={didScreenTransitionEnd}
textInputLabel={props.translate('optionsSelector.nameEmailOrPhoneNumber')}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
autoFocus={false}
ref={optionRef}
/>
</View>
</>
Expand Down

0 comments on commit ae30313

Please sign in to comment.