From e72e628c817d5c63c4d7545952f37441842951cd Mon Sep 17 00:00:00 2001 From: ralf Date: Fri, 2 Dec 2022 14:42:36 +0100 Subject: [PATCH] give focus back to previous active element instead of focusing on first input --- api/js/etemplate/et2_widget_htmlarea.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/et2_widget_htmlarea.ts b/api/js/etemplate/et2_widget_htmlarea.ts index bf23569e33..e1432ae7a5 100644 --- a/api/js/etemplate/et2_widget_htmlarea.ts +++ b/api/js/etemplate/et2_widget_htmlarea.ts @@ -305,13 +305,14 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable self.resetDirty(); if (self.editor && self.editor.editorContainer) { + const activeElement = document.activeElement; self.editor.formatter.toggle(rte_formatblock); jQuery(self.editor.editorContainer).height(self.options.height); jQuery(self.editor.iframeElement.contentWindow.document).on('dragenter', function(){ if (jQuery('#dragover-tinymce').length < 1) jQuery("").appendTo('head'); }); - //set back focus to the first field in the form - self.getInstanceManager().focusOnFirstInput(); + // give focus back + activeElement && activeElement.focus && activeElement.focus(); } }); }