Skip to content

Commit

Permalink
fix/22534-draft-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanDylann committed Nov 10, 2023
1 parent 1928c95 commit 1c5fd83
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/pages/workspace/SearchInputRef.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import {TextInput} from 'react-native';

const searchInputRef = React.createRef<TextInput>();
let onSearchInputChange: (text: string) => void = () => {};

Check failure on line 5 in src/pages/workspace/SearchInputRef.ts

View workflow job for this annotation

GitHub Actions / lint / lint

'onSearchInputChange' is never reassigned. Use 'const' instead
let searchInput: string = '';

Check failure on line 6 in src/pages/workspace/SearchInputRef.ts

View workflow job for this annotation

GitHub Actions / lint / lint

Type string trivially inferred from a string literal, remove type annotation

Check failure on line 6 in src/pages/workspace/SearchInputRef.ts

View workflow job for this annotation

GitHub Actions / lint / lint

'searchInput' is never reassigned. Use 'const' instead
export default {
searchInputRef,
onSearchInputChange,
searchInput,
};
14 changes: 13 additions & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SearchInputRef from './SearchInputRef';
import {policyDefaultProps, policyPropTypes} from './withPolicy';
import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading';

Expand Down Expand Up @@ -225,6 +226,14 @@ function WorkspaceInvitePage(props) {
return OptionsListUtils.getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue);
}, [excludedUsers, translate, searchTerm, policyName, usersToInvite, personalDetails.length]);

useEffect(() => {
if (!SearchInputRef.searchInput) {
return;
}
if (SearchInputRef.searchInput) {
setSearchTerm(SearchInputRef.searchInput);
}
}, []);
return (
<ScreenWrapper
shouldEnableMaxHeight
Expand Down Expand Up @@ -254,7 +263,10 @@ function WorkspaceInvitePage(props) {
sections={sections}
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
textInputValue={searchTerm}
onChangeText={setSearchTerm}
onChangeText={(value) => {
SearchInputRef.searchInput = value;
setSearchTerm(value);
}}
headerMessage={headerMessage}
onSelectRow={toggleOption}
onConfirm={inviteUser}
Expand Down
17 changes: 15 additions & 2 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
Expand Down Expand Up @@ -32,6 +33,7 @@ import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SearchInputRef from './SearchInputRef';
import {policyDefaultProps, policyPropTypes} from './withPolicy';
import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading';

Expand Down Expand Up @@ -402,7 +404,15 @@ function WorkspaceMembersPage(props) {
/>
);
};

const isFocusedScreen = useIsFocused();
useEffect(() => {
if (!SearchInputRef.searchInput) {
return;
}
if (SearchInputRef.searchInput) {
setSearchValue(SearchInputRef.searchInput);
}
}, [isFocusedScreen]);
return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down Expand Up @@ -465,7 +475,10 @@ function WorkspaceMembersPage(props) {
sections={[{data, indexOffset: 0, isDisabled: false}]}
textInputLabel={props.translate('optionsSelector.findMember')}
textInputValue={searchValue}
onChangeText={setSearchValue}
onChangeText={(value) => {
SearchInputRef.searchInput = value;
setSearchValue(value);
}}
headerMessage={getHeaderMessage()}
headerContent={getHeaderContent()}
onSelectRow={(item) => toggleUser(item.accountID)}
Expand Down

0 comments on commit 1c5fd83

Please sign in to comment.