Skip to content

Commit

Permalink
Merge pull request #38861 from Krishna2323/krishna2323/issue/37656
Browse files Browse the repository at this point in the history
fix: Room - WS is not selected when filtered from newdot.
  • Loading branch information
AndrewGable authored Mar 29, 2024
2 parents 25b85a9 + bcff79f commit faff990
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/pages/workspace/WorkspaceNewRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import RoomNameInput from '@components/RoomNameInput';
import ScreenWrapper from '@components/ScreenWrapper';
import TextInput from '@components/TextInput';
import ValuePicker from '@components/ValuePicker';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand Down Expand Up @@ -69,6 +70,9 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
const wasLoading = usePrevious<boolean>(!!formState?.isLoading);
const visibilityDescription = useMemo(() => translate(`newRoomPage.${visibility}Description`), [translate, visibility]);
const {isLoading = false, errorFields = {}} = formState ?? {};
const {activeWorkspaceID} = useActiveWorkspace();

const activeWorkspaceOrDefaultID = activeWorkspaceID ?? activePolicyID;

const workspaceOptions = useMemo(
() =>
Expand All @@ -82,8 +86,8 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
[policies],
);
const [policyID, setPolicyID] = useState<string>(() => {
if (!!activePolicyID && workspaceOptions.some((option) => option.value === activePolicyID)) {
return activePolicyID;
if (!!activeWorkspaceOrDefaultID && workspaceOptions.some((option) => option.value === activeWorkspaceOrDefaultID)) {
return activeWorkspaceOrDefaultID;
}
return '';
});
Expand Down Expand Up @@ -132,12 +136,12 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
}
return;
}
if (!!activePolicyID && workspaceOptions.some((opt) => opt.value === activePolicyID)) {
setPolicyID(activePolicyID);
if (!!activeWorkspaceOrDefaultID && workspaceOptions.some((opt) => opt.value === activeWorkspaceOrDefaultID)) {
setPolicyID(activeWorkspaceOrDefaultID);
} else {
setPolicyID('');
}
}, [activePolicyID, policyID, workspaceOptions]);
}, [activeWorkspaceOrDefaultID, policyID, workspaceOptions]);

useEffect(() => {
if (!(((wasLoading && !isLoading) || (isOffline && isLoading)) && isEmptyObject(errorFields))) {
Expand Down

0 comments on commit faff990

Please sign in to comment.