From 9733c396fe1ca31f584b2775a7ff59ae7b2b4914 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 2 Sep 2013 12:56:37 +0200 Subject: [PATCH] [FIX] correctly select range after inserting a link in the document Apparently same issue as noted in xmo@openerp.com-20130902105411-ni3klun0k8v1tmjg, RTE and bootstrap modal fight for focus (oddly not in Firefox), leading to the callstack blowing up (after a fraction of a second of browser freezing). Use same remedy, defer focus-manipulating operation to after the dialog has been removed and destroyed in order to avoid focus fight. bzr revid: xmo@openerp.com-20130902105637-1y9aogm1yx9z81jt --- addons/website/static/src/js/website.editor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index ee14b113e8e..912d3705286 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -384,9 +384,12 @@ element: 'a', attributes: attributes, }).applyToRange(range); - // blows up the call stack, not sure why as original version - // seems to work OK - // range.select(); + + // focus dance between RTE & dialog blow up the stack in Safari + // and Chrome, so defer select() until dialog has been closed + setTimeout(function () { + range.select(); + }, 0); } }, save: function () {