From ccba7badff89494e6bede69d84494e5557cf268a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 8 Oct 2021 14:33:58 +0100 Subject: [PATCH] Make public space alias field mandatory again --- src/components/views/elements/Field.tsx | 4 ++++ src/components/views/spaces/SpaceCreateMenu.tsx | 11 +++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/views/elements/Field.tsx b/src/components/views/elements/Field.tsx index 5713518eb84..476b0f73c79 100644 --- a/src/components/views/elements/Field.tsx +++ b/src/components/views/elements/Field.tsx @@ -143,6 +143,10 @@ export default class Field extends React.PureComponent { public focus() { this.input.focus(); + // programmatic does not fire onFocus handler + this.setState({ + focused: true, + }); } private onFocus = (ev) => { diff --git a/src/components/views/spaces/SpaceCreateMenu.tsx b/src/components/views/spaces/SpaceCreateMenu.tsx index 1d63f85f71c..22cbb4db656 100644 --- a/src/components/views/spaces/SpaceCreateMenu.tsx +++ b/src/components/views/spaces/SpaceCreateMenu.tsx @@ -214,7 +214,6 @@ export const SpaceCreateForm: React.FC = ({ }; const SpaceCreateMenu = ({ onFinished }) => { - const cli = useContext(MatrixClientContext); const [visibility, setVisibility] = useState(null); const [busy, setBusy] = useState(false); @@ -238,13 +237,9 @@ const SpaceCreateMenu = ({ onFinished }) => { return; } - // validate the space alias field but do not require it - const aliasLocalpart = alias.substring(1, alias.length - cli.getDomain().length - 1); - if (visibility === Visibility.Public && aliasLocalpart && - (await spaceAliasField.current.validate({ allowEmpty: true })) === false - ) { + if (visibility === Visibility.Public && !(await spaceAliasField.current.validate({ allowEmpty: false }))) { spaceAliasField.current.focus(); - spaceAliasField.current.validate({ allowEmpty: true, focused: true }); + spaceAliasField.current.validate({ allowEmpty: false, focused: true }); setBusy(false); return; } @@ -253,7 +248,7 @@ const SpaceCreateMenu = ({ onFinished }) => { await createSpace( name, visibility === Visibility.Public, - aliasLocalpart ? alias : undefined, + alias, topic, avatar, );