Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Room - WS is not selected when filtered from newdot. #38861

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading