From 902e484f14455eabdecc14896944046a53e5ee94 Mon Sep 17 00:00:00 2001 From: David Beguin Date: Mon, 6 Aug 2018 11:22:38 +0200 Subject: [FIX] ClipboardJS update for Bootstrap Modals focus issue in Chrome Since Bootstrap 4, ClipboardJS does not copy the value in the clipboard anymore as Bootstraps modals give the focus to another element. As the focus need to be given back to the correct element, ClipboardJS has to be updated as the container parameter is only added in v1.7. We were in 1.5. That container parameter allow to give the focus back to the correct element. See doc on https://clipboardjs.com/ + Issue : https://github.com/zenorocha/clipboard.js/issues/155 --- addons/web/static/src/js/fields/basic_fields.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 9d0f62b5ebc..f209925f37c 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1100,10 +1100,14 @@ var CopyClipboard = { var self = this; var $clipboardBtn = this.$('.o_clipboard_button'); $clipboardBtn.tooltip({title: _t('Copied !'), trigger: 'manual', placement: 'right'}); - this.clipboard = new Clipboard($clipboardBtn.get(0), { - text: function () { - return self.value.trim(); - } + this.clipboard = new ClipboardJS($clipboardBtn[0], { + text: function (_) { + return self.value.trim(); + }, + // Container added because of Bootstrap modal that give the focus to another element. + // We need to give to correct focus to ClipboardJS (see in ClipboardJS doc) + // https://github.com/zenorocha/clipboard.js/issues/155 + container: self.$el[0] }); this.clipboard.on('success', function () { _.defer(function () { -- cgit v1.2.3