mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +00:00
dialog input autofocus
This commit is contained in:
@@ -12,6 +12,12 @@ class CreateGroupDialog extends React.Component {
|
|||||||
groupName: '',
|
groupName: '',
|
||||||
errorMsg: '',
|
errorMsg: '',
|
||||||
};
|
};
|
||||||
|
this.newInput = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.newInput.focus();
|
||||||
|
this.newInput.setSelectionRange(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGroupChange = (event) => {
|
handleGroupChange = (event) => {
|
||||||
@@ -51,6 +57,7 @@ class CreateGroupDialog extends React.Component {
|
|||||||
handleKeyDown = (e) => {
|
handleKeyDown = (e) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
this.handleSubmitGroup();
|
this.handleSubmitGroup();
|
||||||
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +67,14 @@ class CreateGroupDialog extends React.Component {
|
|||||||
<ModalHeader toggle={this.props.toggleAddGroupModal}>{gettext('New Group')}</ModalHeader>
|
<ModalHeader toggle={this.props.toggleAddGroupModal}>{gettext('New Group')}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<label htmlFor="groupName">{gettext('Name')}</label>
|
<label htmlFor="groupName">{gettext('Name')}</label>
|
||||||
<Input type="text" id="groupName" value={this.state.groupName}
|
<Input
|
||||||
onChange={this.handleGroupChange} onKeyDown={this.handleKeyDown}/>
|
innerRef={input => {this.newInput = input;}}
|
||||||
|
type="text"
|
||||||
|
id="groupName"
|
||||||
|
value={this.state.groupName}
|
||||||
|
onChange={this.handleGroupChange}
|
||||||
|
onKeyDown={this.handleKeyDown}
|
||||||
|
/>
|
||||||
<span className="error">{this.state.errorMsg}</span>
|
<span className="error">{this.state.errorMsg}</span>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
|
@@ -17,6 +17,12 @@ class AddDepartDialog extends React.Component {
|
|||||||
departName: '',
|
departName: '',
|
||||||
errMessage: '',
|
errMessage: '',
|
||||||
};
|
};
|
||||||
|
this.newInput = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.newInput.focus();
|
||||||
|
this.newInput.setSelectionRange(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = () => {
|
handleSubmit = () => {
|
||||||
@@ -74,6 +80,7 @@ class AddDepartDialog extends React.Component {
|
|||||||
onKeyPress={this.handleKeyPress}
|
onKeyPress={this.handleKeyPress}
|
||||||
value={this.state.departName}
|
value={this.state.departName}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
|
innerRef={input => {this.newInput = input;}}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Form>
|
</Form>
|
||||||
|
@@ -17,6 +17,12 @@ class AddRepoDialog extends React.Component {
|
|||||||
repoName: '',
|
repoName: '',
|
||||||
errMessage: '',
|
errMessage: '',
|
||||||
};
|
};
|
||||||
|
this.newInput = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.newInput.focus();
|
||||||
|
this.newInput.setSelectionRange(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = () => {
|
handleSubmit = () => {
|
||||||
@@ -69,6 +75,7 @@ class AddRepoDialog extends React.Component {
|
|||||||
onKeyPress={this.handleKeyPress}
|
onKeyPress={this.handleKeyPress}
|
||||||
value={this.state.repoName}
|
value={this.state.repoName}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
|
innerRef={input => {this.newInput = input;}}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Form>
|
</Form>
|
||||||
|
@@ -18,6 +18,12 @@ class SetGroupQuotaDialog extends React.Component {
|
|||||||
quota: '',
|
quota: '',
|
||||||
errMessage: '',
|
errMessage: '',
|
||||||
};
|
};
|
||||||
|
this.newInput = React.createRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.newInput.focus();
|
||||||
|
this.newInput.setSelectionRange(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
setGroupQuota = () => {
|
setGroupQuota = () => {
|
||||||
@@ -58,6 +64,7 @@ class SetGroupQuotaDialog extends React.Component {
|
|||||||
onKeyPress={this.handleKeyPress}
|
onKeyPress={this.handleKeyPress}
|
||||||
value={this.state.quota}
|
value={this.state.quota}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
|
innerRef={input => {this.newInput = input;}}
|
||||||
/>
|
/>
|
||||||
<InputGroupAddon addonType="append">{'MB'}</InputGroupAddon>
|
<InputGroupAddon addonType="append">{'MB'}</InputGroupAddon>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
Reference in New Issue
Block a user