1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 00:43:53 +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 = () => { toggle = () => {
if (this.props.isFile) { if (this.props.isFile) {
this.props.addFileCancel(); this.props.addFileCancel();
@@ -83,7 +89,7 @@ class CreateFileForder extends React.Component {
<FormGroup row> <FormGroup row>
<Label for="fileName" sm={3}>{gettext("Name")}: </Label> <Label for="fileName" sm={3}>{gettext("Name")}: </Label>
<Col sm={9}> <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> </Col>
</FormGroup> </FormGroup>
</Form> </Form>

View File

@@ -21,6 +21,12 @@ class Rename extends React.Component {
this.props.onRename(this.state.newName); this.props.onRename(this.state.newName);
} }
handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.handleSubmit()
}
}
toggle = () => { toggle = () => {
this.props.toggleCancel(); 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> <ModalHeader toggle={this.toggle}>{type === 'file' ? gettext("Rename File") : gettext("Rename Folder") }</ModalHeader>
<ModalBody> <ModalBody>
<p>{type === 'file' ? gettext("Enter the new file name:"): gettext("Enter the new folder name:")}</p> <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> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="primary" onClick={this.handleSubmit}>{gettext("Submit")}</Button> <Button color="primary" onClick={this.handleSubmit}>{gettext("Submit")}</Button>