Skip to content

Commit

Permalink
fix transition for task assignee modals
Browse files Browse the repository at this point in the history
  • Loading branch information
b4s36t4 committed Sep 12, 2023
1 parent 662af46 commit a7728d4
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 @@ -78,6 +78,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 @@ -195,7 +197,10 @@ function TaskAssigneeSelectorModal(props) {
};

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
onEntryTransitionEnd={() => optionRef.current && optionRef.current.textInput.focus()}
>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
<>
<HeaderWithBackButton
Expand All @@ -213,6 +218,8 @@ function TaskAssigneeSelectorModal(props) {
shouldShowOptions={didScreenTransitionEnd && !isLoading}
textInputLabel={props.translate('optionsSelector.nameEmailOrPhoneNumber')}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
autoFocus={false}
ref={optionRef}
/>
</View>
</>
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 @@ -107,7 +109,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 @@ -127,6 +132,8 @@ function TaskShareDestinationSelectorModal(props) {
shouldShowOptions={didScreenTransitionEnd}
textInputLabel={props.translate('optionsSelector.nameEmailOrPhoneNumber')}
safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle}
autoFocus={false}
ref={optionRef}
/>
</View>
</>
Expand Down

0 comments on commit a7728d4

Please sign in to comment.