# Setting the Initial Focus on the Editor when the Dialog or Window is Opened

## Environment

<table>
    <tbody>
	    <tr>
	    	<td>Product</td>
	    	<td>Progress® Kendo UI® for Angular Editor</td>
            <td>Progress® Kendo UI® for Angular Dialogs</td>
	    </tr>
    </tbody>
</table>

## Description

When using the Kendo UI Editor inside an Angular Dialog or Window, setting focus automatically to the editor can be challenging due to the editor's delayed rendering. This prevents the [`autoFocusedElement`](https://www.telerik.com/kendo-angular-ui/components/dialogs/api/dialogcomponent#autofocusedelement) from working as expected. This article demonstrates how to set the initial focus on the Editor when the Dialog or Window is opened.

This knowledge base article also answers the following questions:

* How to automatically focus the Editor in an Angular Dialog and Window?
* What is the workaround for focusing elements with delayed rendering in Angular?
* Can I focus the Kendo UI Editor when opening an Angular Dialog or Window?

## Solution

Handle the opening of the Dialog or Window component and use the Editor's [`focus`](https://www.telerik.com/kendo-angular-ui/components/editor/api/editorcomponent#focus) method to set the initial focus on the Editor. You should use some delay to ensure that the Editor is rendered before focusing it. The solution can be implemented in both Dialog and Window components.

The following example demonstrates how to focus the Editor when the Dialog is opened using rxjs observables and the `delay` operator.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/focusing-editor-when-opening-dialog/source.txt)

## See Also

* [Initial Focus in Kendo Angular Dialog](https://www.telerik.com/kendo-angular-ui/components/dialogs/dialog/initial-focus)
* [Initial Focus in Kendo Angular Window](https://www.telerik.com/kendo-angular-ui/components/dialogs/window/initial-focus)
* [API Reference of the `DialogComponent`](https://www.telerik.com/kendo-angular-ui/components/dialogs/api/dialogcomponent)
* [API Reference of the `WindowComponent`](https://www.telerik.com/kendo-angular-ui/components/dialogs/api/windowcomponent)
* [API Reference of the `EditorComponent`](https://www.telerik.com/kendo-angular-ui/components/editor/api/editorcomponent)
