1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

Update dependency 3 (#5344)

* update react react-dom prop-types

* update seafile-editor version

* install deep-copy denpendency

* update router version

* repair focus bug

* optimize code

* optimize code
This commit is contained in:
杨顺强
2022-12-24 10:41:34 +08:00
committed by GitHub
parent bf313b947c
commit 3faa4acb8e
70 changed files with 669 additions and 1297 deletions

View File

@@ -28,16 +28,8 @@ class Rename extends React.Component {
}
componentDidMount() {
let {dirent} = this.props;
let { dirent } = this.props;
this.changeState(dirent);
this.newInput.focus();
let type = dirent.type;
if (type === 'file') {
var endIndex = dirent.name.lastIndexOf('.md');
this.newInput.setSelectionRange(0, endIndex, 'forward');
} else {
this.newInput.setSelectionRange(0, -1);
}
}
componentWillReceiveProps(nextProps) {
@@ -110,14 +102,28 @@ class Rename extends React.Component {
return isDuplicated;
}
onAfterModelOpened = () => {
if (!this.newInput.current) return;
this.newInput.current.focus();
let { dirent } = this.props;
let type = dirent.type;
if (type === 'file') {
var endIndex = dirent.name.lastIndexOf('.md');
this.newInput.current.setSelectionRange(0, endIndex, 'forward');
} else {
this.newInput.current.setSelectionRange(0, -1);
}
}
render() {
let type = this.props.dirent.type;
return (
<Modal isOpen={true} toggle={this.toggle}>
<Modal isOpen={true} toggle={this.toggle} onOpened={this.onAfterModelOpened}>
<ModalHeader toggle={this.toggle}>{type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }</ModalHeader>
<ModalBody>
<p>{type === 'file' ? gettext('New file name'): gettext('New folder name')}</p>
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input;}} value={this.state.newName} onChange={this.handleChange} />
<Input onKeyPress={this.handleKeyPress} innerRef={this.newInput} value={this.state.newName} onChange={this.handleChange} />
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
</ModalBody>
<ModalFooter>