1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00

add keypress (#2303)

This commit is contained in:
C_Q
2018-08-27 17:12:27 +08:00
committed by Daniel Pan
parent a97f9f2b0c
commit edbcc8a78b
2 changed files with 14 additions and 2 deletions

View File

@@ -27,6 +27,12 @@ class CreateFileForder extends React.Component {
}
}
handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
}
}
toggle = () => {
if (this.props.isFile) {
this.props.addFileCancel();
@@ -83,7 +89,7 @@ class CreateFileForder extends React.Component {
<FormGroup row>
<Label for="fileName" sm={3}>{gettext("Name")}: </Label>
<Col sm={9}>
<Input innerRef={input => {this.newInput = input}} id="fileName" placeholder={gettext("newName")} value={this.state.childName} onChange={this.handleChange}/>
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input}} id="fileName" placeholder={gettext("newName")} value={this.state.childName} onChange={this.handleChange}/>
</Col>
</FormGroup>
</Form>

View File

@@ -21,6 +21,12 @@ class Rename extends React.Component {
this.props.onRename(this.state.newName);
}
handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.handleSubmit()
}
}
toggle = () => {
this.props.toggleCancel();
}
@@ -59,7 +65,7 @@ class Rename extends React.Component {
<ModalHeader toggle={this.toggle}>{type === 'file' ? gettext("Rename File") : gettext("Rename Folder") }</ModalHeader>
<ModalBody>
<p>{type === 'file' ? gettext("Enter the new file name:"): gettext("Enter the new folder name:")}</p>
<Input innerRef={input => {this.newInput = input}} placeholder="newName" value={this.state.newName} onChange={this.handleChange} />
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input}} placeholder="newName" value={this.state.newName} onChange={this.handleChange} />
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.handleSubmit}>{gettext("Submit")}</Button>