summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2018-08-06 11:22:38 +0200
committerDavid Beguin <dbe@odoo.com>2018-08-06 11:34:51 +0200
commit902e484f14455eabdecc14896944046a53e5ee94 (patch)
tree0b8f54112cd27e73521b5f2447902903aa6c7de4 /addons/web/static/src/js/fields
parentf7cce79cfe3509955048aca2424bbc17b0867577 (diff)
[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
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js12
1 files changed, 8 insertions, 4 deletions
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 () {