Skip to content

Commit

Permalink
Set input curser to the end of the title
Browse files Browse the repository at this point in the history
  • Loading branch information
schoettl committed Dec 28, 2019
1 parent e36ab63 commit 09d6fff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/OrgFile/components/TitleLine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TitleLine extends PureComponent {
'handleTextareaRef',
'handleTitleClick',
'handleTextareaBlur',
'handleTextareaFocus',
'handleTitleChange',
'handleTitleFieldClick',
'handleTodoClick',
Expand Down Expand Up @@ -134,6 +135,12 @@ class TitleLine extends PureComponent {
}, 0);
}

handleTextareaFocus(event) {
const text = event.target.value;
event.target.selectionStart = text.length;
event.target.selectionEnd = text.length;
}

handleTitleChange(event) {
// If the last character typed was a newline at the end, exit edit mode.
const newTitle = event.target.value;
Expand Down Expand Up @@ -226,6 +233,7 @@ class TitleLine extends PureComponent {
ref={this.handleTextareaRef}
value={this.state.titleValue}
onBlur={this.handleTextareaBlur}
onFocus={this.handleTextareaFocus}
onChange={this.handleTitleChange}
onClick={this.handleTitleFieldClick}
/>
Expand Down

0 comments on commit 09d6fff

Please sign in to comment.