Update OutlineViewItem to focus end of input when editing

This commit is contained in:
Juan Tejada 2016-01-28 00:02:55 -08:00
parent bf2cebc08f
commit 8b0a3a69db
3 changed files with 8 additions and 0 deletions

View file

@ -42,6 +42,7 @@ onDeleteItem = (item) ->
Actions.queueTask(new DestroyCategoryTask({category}))
onEditItem = (item, value) ->
return unless value
return if item.deleted is true
category = item.perspective.category()
return unless category

View file

@ -139,6 +139,7 @@ class SidebarSection
collapsed: collapsed
onToggleCollapsed: onToggleCollapsed
onItemCreated: (displayName) ->
return unless displayName
category = new Category
displayName: displayName
accountId: account.id

View file

@ -130,6 +130,11 @@ class OutlineViewItem extends Component {
this.setState({editing: true});
}
_onInputFocus = (event)=> {
const input = event.target;
input.selectionStart = input.selectionEnd = input.value.length;
}
_onInputBlur = (event)=> {
this._clearEditingState(event);
}
@ -202,6 +207,7 @@ class OutlineViewItem extends Component {
placeholder={placeholder}
defaultValue={item.name}
onBlur={this._onInputBlur}
onFocus={this._onInputFocus}
onKeyDown={this._onInputKeyDown} />
);
}