From 14bb9c10b94e7cef4b5664e06a5a45a942253628 Mon Sep 17 00:00:00 2001 From: Musale Martin Date: Fri, 2 Feb 2024 23:04:30 +0300 Subject: [PATCH] fix: focus on the input when you cancel adding a todo (#3005) --- .../mgt-components/src/components/mgt-todo/mgt-todo.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/mgt-components/src/components/mgt-todo/mgt-todo.ts b/packages/mgt-components/src/components/mgt-todo/mgt-todo.ts index 9968f6d171..22bc33fe19 100644 --- a/packages/mgt-components/src/components/mgt-todo/mgt-todo.ts +++ b/packages/mgt-components/src/components/mgt-todo/mgt-todo.ts @@ -555,6 +555,15 @@ export class MgtTodo extends MgtTasksBase { this._newTaskName = ''; this._changedTaskName = ''; this._isChangedDueDate = false; + this.focusOnTaskInput(); + }; + + protected focusOnTaskInput = (): void => { + const taskInputWrapper = this.renderRoot.querySelector('#new-task-name-input'); + const input = taskInputWrapper?.shadowRoot.querySelector('input'); + if (input) { + input.focus(); + } }; /**