1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 09:21:54 +00:00

When it is empty, submit btn is disabled

This commit is contained in:
zxj96
2019-05-17 11:09:05 +08:00
parent 398c9f3f96
commit d70051f087
8 changed files with 66 additions and 21 deletions

View File

@@ -11,6 +11,7 @@ class CreateGroupDialog extends React.Component {
this.state = {
groupName: '',
errorMsg: '',
isSubmitBtnActive: false,
};
this.newInput = React.createRef();
}
@@ -22,6 +23,12 @@ class CreateGroupDialog extends React.Component {
handleGroupChange = (event) => {
let name = event.target.value;
if (!name.trim()) {
this.setState({isSubmitBtnActive: false});
} else {
this.setState({isSubmitBtnActive: true});
}
this.setState({
groupName: name
});
@@ -79,7 +86,7 @@ class CreateGroupDialog extends React.Component {
</ModalBody>
<ModalFooter>
<Button color="secondary" onClick={this.props.toggleAddGroupModal}>{gettext('Cancel')}</Button>
<Button color="primary" onClick={this.handleSubmitGroup}>{gettext('Submit')}</Button>
<Button color="primary" onClick={this.handleSubmitGroup} disabled={!this.state.isSubmitBtnActive}>{gettext('Submit')}</Button>
</ModalFooter>
</Modal>
);