From dd4acab1626340ed54d0950fdf6469d76b9a6fe9 Mon Sep 17 00:00:00 2001 From: David Bondy Date: Tue, 29 Oct 2024 12:56:16 -0600 Subject: [PATCH] Merge pull request #51684 from Expensify/georgia-test [CP Staging] Allow input on members page (cherry picked from commit 3edc346319174eba90b494bc1f06c2f28056d4bd) (CP triggered by Beamanator) --- src/pages/RoomMembersPage.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) 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)}