@@ -24,6 +24,7 @@ internal class ActionsTreeView : ViewBase<ActionsTreeView.ViewState>
2424 private readonly ScrollView m_PropertiesScrollview ;
2525
2626 private bool m_RenameOnActionAdded ;
27+ private bool m_FocusOnRenameActionFinish ;
2728 private readonly CollectionViewSelectionChangeFilter m_ActionsTreeViewSelectionChangeFilter ;
2829
2930 //save TreeView element id's of individual input actions and bindings to ensure saving of expanded state
@@ -215,6 +216,8 @@ public override void RedrawUI(ViewState viewState)
215216
216217 // Don't want to show action properties if there's no actions.
217218 m_PropertiesScrollview . visible = m_ActionsTreeView . GetTreeCount ( ) > 0 ;
219+
220+ FinishActionRename ( viewState . newElementID ) ;
218221 }
219222
220223 private void OnDraggedItem ( DragPerformEvent evt )
@@ -307,6 +310,17 @@ internal void RenameActionItem(int index)
307310 m_ActionsTreeView . ScrollToItem ( index ) ;
308311 m_ActionsTreeView . GetRootElementForIndex ( index ) ? . Q < InputActionsTreeViewItem > ( ) ? . FocusOnRenameTextField ( ) ;
309312 }
313+
314+ private void FinishActionRename ( int id )
315+ {
316+ if ( ! m_FocusOnRenameActionFinish || id == - 1 )
317+ return ;
318+ m_ActionsTreeView . ScrollToItemById ( id ) ;
319+ var treeViewItem = m_ActionsTreeView . GetRootElementForId ( id ) ? . Q < InputActionsTreeViewItem > ( ) ;
320+ treeViewItem ? . FocusOnRenameFinish ( ) ;
321+
322+ m_FocusOnRenameActionFinish = false ;
323+ }
310324
311325 internal void AddAction ( )
312326 {
@@ -369,6 +383,8 @@ private void ChangeActionOrCompositName(ActionOrBindingData data, string newName
369383 Dispatch ( Commands . ChangeActionName ( data . actionMapIndex , data . name , newName ) ) ;
370384 else if ( data . isComposite )
371385 Dispatch ( Commands . ChangeCompositeName ( data . actionMapIndex , data . bindingIndex , newName ) ) ;
386+
387+ m_FocusOnRenameActionFinish = true ;
372388 }
373389
374390 internal int GetMapCount ( )
0 commit comments