1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 19:29:56 +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 = () => { 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 { inputElement.select();
this.newInput.current.setSelectionRange(0, -1); }
} }
}; };