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

Commit

Permalink
Merge pull request #6921 from matrix-org/t3chguy/fix/19003.1
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 14, 2021
2 parents 2a3c483 + ccba7ba commit 53d7c9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
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

0 comments on commit 53d7c9d

Please sign in to comment.