diff options
| author | Benjamin Vray <bvr@odoo.com> | 2020-05-18 15:04:31 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2020-07-28 12:20:16 +0000 |
| commit | 4848c3aed729c70f10dacc46a19d95b4ea064191 (patch) | |
| tree | c9a7e4b18a34a1735be36f2675d90f73f0db0aa7 /addons/web_editor/static/src/js | |
| parent | 2ebbdef089f05e22ab735b37cff930e89f0efb79 (diff) | |
[FIX] web_editor: fix overlay when scrolling
Since the new effects on the header, the overlays do not overlap
correctly after the page has been scrolled. Now we hide the overlays
during the scrolling and show/recompute it after the scrolling.
Part of https://github.com/odoo/odoo/pull/51446
task-2229127
X-original-commit: 209a94d8c4fcdc2e74860c9392fc14a35aec52ed
Diffstat (limited to 'addons/web_editor/static/src/js')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.editor.js | 33 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.options.js | 2 |
2 files changed, 26 insertions, 9 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 3dfe8a06ffd..7ded24d6830 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -391,11 +391,11 @@ var SnippetEditor = Widget.extend({ return show; }, /** - * @param {boolean} [isTextEdition=false] + * @param {boolean} [show=false] */ - toggleTextEdition: function (isTextEdition) { - if (this.$el) { - this.$el.toggleClass('o_keypress', !!isTextEdition && this.isShown()); + toggleOverlayVisibility: function (show) { + if (this.$el && !this.scrollingTimeout) { + this.$el.toggleClass('o_overlay_hidden', !show && this.isShown()); } }, /** @@ -978,14 +978,31 @@ var SnippetsMenu = Widget.extend({ // again when the mouse moves this.$document.on('keydown.snippets_menu', () => { this.snippetEditors.forEach(editor => { - editor.toggleTextEdition(true); + editor.toggleOverlayVisibility(false); }); }); - this.$document.on('mousemove.snippets_menu, mousedown.snippets_menu', () => { + this.$document.on('mousemove.snippets_menu, mousedown.snippets_menu', _.throttle(() => { this.snippetEditors.forEach(editor => { - editor.toggleTextEdition(false); + editor.toggleOverlayVisibility(true); }); - }); + }, 250)); + + // Hide the active overlay when scrolling. + // Show it again and recompute all the overlays after the scroll. + // TODO: current limitation, suppose that this is the body which scrolls + this.$document.on('scroll.snippets_menu', _.throttle(() => { + for (const editor of this.snippetEditors) { + editor.toggleOverlayVisibility(false); + } + clearTimeout(this.scrollingTimeout); + this.scrollingTimeout = setTimeout(() => { + this._scrollingTimeout = null; + for (const editor of this.snippetEditors) { + editor.toggleOverlayVisibility(true); + editor.cover(); + } + }, 250); + }, 50)); // Auto-selects text elements with a specific class and remove this // on text changes diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index daa53fb7dae..ff2aea2d7b7 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -3697,7 +3697,7 @@ registry.many2one = SnippetOptionWidget.extend({ this.$search.find('input') .focus() .on('keyup', function (e) { - self.$overlay.removeClass('o_keypress'); + self.$overlay.removeClass('o_overlay_hidden'); self._findExisting($(this).val()); }); |
