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:
@@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user