1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 02:10:24 +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:
Aries
2024-07-18 11:54:50 +08:00
committed by GitHub
parent 77def3b1f6
commit c5d02b33b2

View File

@@ -104,16 +104,16 @@ class Rename extends React.Component {
};
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);
const inputElement = this.newInput.current;
if (inputElement) {
inputElement.focus();
const filename = this.state.newName;
const lastDotIndex = filename.lastIndexOf('.');
if (lastDotIndex > 0) {
inputElement.setSelectionRange(0, lastDotIndex);
} else {
inputElement.select();
}
}
};