diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index 1018b86083be..6a89eca6f778 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -19,7 +19,6 @@ import SelectionListWithModal from '@components/SelectionListWithModal'; import Text from '@components/Text'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; -import useDebouncedState from '@hooks/useDebouncedState'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; @@ -55,7 +54,7 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) { const [selectedMembers, setSelectedMembers] = useState([]); const [removeMembersConfirmModalVisible, setRemoveMembersConfirmModalVisible] = useState(false); const [userSearchPhrase] = useOnyx(ONYXKEYS.ROOM_MEMBERS_USER_SEARCH_PHRASE); - const [searchValue, debouncedSearchTerm, setSearchValue] = useDebouncedState(''); + const [searchValue, setSearchValue] = useState(''); const [didLoadRoomMembers, setDidLoadRoomMembers] = useState(false); const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; const policy = useMemo(() => policies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID ?? ''}`], [policies, report?.policyID]); @@ -71,14 +70,6 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) { const [selectionMode] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE); const canSelectMultiple = isSmallScreenWidth ? selectionMode?.isEnabled : true; - useEffect(() => { - setSearchValue(userSearchPhrase ?? ''); - }, [isFocusedScreen, setSearchValue, userSearchPhrase]); - - useEffect(() => { - UserSearchPhraseActions.updateUserSearchPhrase(debouncedSearchTerm); - }, [debouncedSearchTerm]); - useEffect(() => { if (isFocusedScreen) { return; @@ -195,6 +186,17 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) { return activeParticipants.length >= CONST.SHOULD_SHOW_MEMBERS_SEARCH_INPUT_BREAKPOINT; }, [participants, personalDetails, isOffline, report]); + useEffect(() => { + if (!isFocusedScreen || !shouldShowTextInput) { + return; + } + setSearchValue(userSearchPhrase ?? ''); + }, [isFocusedScreen, shouldShowTextInput, userSearchPhrase]); + + useEffect(() => { + UserSearchPhraseActions.updateUserSearchPhrase(searchValue); + }, [searchValue]); + useEffect(() => { if (!isFocusedScreen) { return; @@ -385,9 +387,7 @@ function RoomMembersPage({report, policies}: RoomMembersPageProps) { textInputLabel={translate('selectionList.findMember')} disableKeyboardShortcuts={removeMembersConfirmModalVisible} textInputValue={searchValue} - onChangeText={(value) => { - setSearchValue(value); - }} + onChangeText={setSearchValue} headerMessage={headerMessage} turnOnSelectionModeOnLongPress onTurnOnSelectionMode={(item) => item && toggleUser(item)}