diff --git a/app/jsx/shared/rce/RichContentEditor.jsx b/app/jsx/shared/rce/RichContentEditor.jsx index 1f2046bf13b..aba7e810448 100644 --- a/app/jsx/shared/rce/RichContentEditor.jsx +++ b/app/jsx/shared/rce/RichContentEditor.jsx @@ -112,16 +112,24 @@ define([ establishParentNode(target) } + const originalOnFocus = tinyMCEInitOptions.onFocus + tinyMCEInitOptions.onFocus = (editor) => { + this.activateRCE(target) + if (typeof originalOnFocus === 'function') { + originalOnFocus(editor) + } + } + loadServiceRCE(target, tinyMCEInitOptions, callback) } else { loadLegacyRCE(target, tinyMCEInitOptions, callback) + + // listen for editor_box_focus events on our target, and trigger + // activateRCE from them + target.on('editor_box_focus', () => this.activateRCE(target)) } hideResizeHandleForScreenReaders() - - // listen for editor_box_focus events on our target, and trigger - // activateRCE from them - target.on('editor_box_focus', () => this.activateRCE(target)) }, /** diff --git a/app/jsx/shared/rce/serviceRCELoader.jsx b/app/jsx/shared/rce/serviceRCELoader.jsx index b17deb0d36f..0c8d7647399 100644 --- a/app/jsx/shared/rce/serviceRCELoader.jsx +++ b/app/jsx/shared/rce/serviceRCELoader.jsx @@ -159,7 +159,8 @@ define([ textareaId: textarea.id, textareaClassName: textarea.className, language: ENV.LOCALE, - mirroredAttrs: this._attrsToMirror(textarea) + mirroredAttrs: this._attrsToMirror(textarea), + onFocus: tinyMCEInitOptions.onFocus } }, diff --git a/spec/coffeescripts/jsx/shared/rce/RichContentEditorSpec.coffee b/spec/coffeescripts/jsx/shared/rce/RichContentEditorSpec.coffee index 570a6547c18..cdda6ff9f5f 100644 --- a/spec/coffeescripts/jsx/shared/rce/RichContentEditorSpec.coffee +++ b/spec/coffeescripts/jsx/shared/rce/RichContentEditorSpec.coffee @@ -37,6 +37,7 @@ define [ fixtures.setup() @$target = fixtures.create('