mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 11:21:29 +00:00
Improvement - auto focus filename without extension when renaming (#6364)
* Improvement - auto focus filename without extension when renaming * code formatting
This commit is contained in:
@@ -104,16 +104,16 @@ class Rename extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onAfterModelOpened = () => {
|
onAfterModelOpened = () => {
|
||||||
if (!this.newInput.current) return;
|
const inputElement = this.newInput.current;
|
||||||
this.newInput.current.focus();
|
if (inputElement) {
|
||||||
|
inputElement.focus();
|
||||||
let { dirent } = this.props;
|
const filename = this.state.newName;
|
||||||
let type = dirent.type;
|
const lastDotIndex = filename.lastIndexOf('.');
|
||||||
if (type === 'file') {
|
if (lastDotIndex > 0) {
|
||||||
var endIndex = dirent.name.lastIndexOf('.md');
|
inputElement.setSelectionRange(0, lastDotIndex);
|
||||||
this.newInput.current.setSelectionRange(0, endIndex, 'forward');
|
|
||||||
} else {
|
} else {
|
||||||
this.newInput.current.setSelectionRange(0, -1);
|
inputElement.select();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user