[Backport staging] Fix create subspace dialog not working (#10656)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
pull/28788/head^2
ElementRobot 2023-04-18 19:00:09 +01:00 committed by GitHub
parent 8a6cf115e1
commit 3b60c8076b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -56,18 +56,22 @@ const CreateSubspaceDialog: React.FC<IProps> = ({ space, onAddExistingSpaceClick
const onCreateSubspaceClick = async (e: ButtonEvent): Promise<void> => { const onCreateSubspaceClick = async (e: ButtonEvent): Promise<void> => {
e.preventDefault(); e.preventDefault();
if (busy || !spaceNameField.current || !spaceAliasField.current) return; if (busy) return;
setBusy(true); setBusy(true);
// require & validate the space name field // require & validate the space name field
if (!(await spaceNameField.current.validate({ allowEmpty: false }))) { if (spaceNameField.current && !(await spaceNameField.current.validate({ allowEmpty: false }))) {
spaceNameField.current.focus(); spaceNameField.current.focus();
spaceNameField.current.validate({ allowEmpty: false, focused: true }); spaceNameField.current.validate({ allowEmpty: false, focused: true });
setBusy(false); setBusy(false);
return; return;
} }
// validate the space name alias field but do not require it // validate the space name alias field but do not require it
if (joinRule === JoinRule.Public && !(await spaceAliasField.current.validate({ allowEmpty: true }))) { if (
spaceAliasField.current &&
joinRule === JoinRule.Public &&
(await spaceAliasField.current.validate({ allowEmpty: true }))
) {
spaceAliasField.current.focus(); spaceAliasField.current.focus();
spaceAliasField.current.validate({ allowEmpty: true, focused: true }); spaceAliasField.current.validate({ allowEmpty: true, focused: true });
setBusy(false); setBusy(false);