diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js index 372938a478e..388b6b6a74f 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link_popover_widget.js @@ -38,7 +38,15 @@ const LinkPopoverWidget = Widget.extend({ this.$fullUrl = this.$('.o_we_full_url'); // Copy onclick handler - const clipboard = new ClipboardJS( + // ClipboardJS uses "instanceof" to verify the elements passed to its + // constructor. Unfortunately, when the element is within an iframe, + // instanceof is not behaving the same across all browsers. + const containerWindow = this.container.ownerDocument.defaultView; + let _ClipboardJS = ClipboardJS; + if (this.$copyLink[0] instanceof containerWindow.HTMLElement) { + _ClipboardJS = containerWindow.ClipboardJS; + } + const clipboard = new _ClipboardJS( this.$copyLink[0], {text: () => this.target.href} // Absolute href );