Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make public space alias field mandatory again #6921

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/components/views/elements/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export default class Field extends React.PureComponent<PropShapes, IState> {

public focus() {
this.input.focus();
// programmatic does not fire onFocus handler
this.setState({
focused: true,
});
}

private onFocus = (ev) => {
Expand Down
11 changes: 3 additions & 8 deletions src/components/views/spaces/SpaceCreateMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export const SpaceCreateForm: React.FC<ISpaceCreateFormProps> = ({
};

const SpaceCreateMenu = ({ onFinished }) => {
const cli = useContext(MatrixClientContext);
const [visibility, setVisibility] = useState<Visibility>(null);
const [busy, setBusy] = useState<boolean>(false);

Expand All @@ -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;
}
Expand All @@ -253,7 +248,7 @@ const SpaceCreateMenu = ({ onFinished }) => {
await createSpace(
name,
visibility === Visibility.Public,
aliasLocalpart ? alias : undefined,
alias,
topic,
avatar,
);
Expand Down