[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
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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 () {
|
||||
|
||||
@@ -107,7 +107,7 @@ if (!$('.o_website_links_create_tracked_url').length) {
|
||||
this.animating_copy = false;
|
||||
},
|
||||
start: function () {
|
||||
new Clipboard(this.$('.btn_shorten_url_clipboard').get(0));
|
||||
new ClipboardJS(this.$('.btn_shorten_url_clipboard').get(0));
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
toggle_copy_button: function () {
|
||||
@@ -289,7 +289,7 @@ if (!$('.o_website_links_create_tracked_url').length) {
|
||||
});
|
||||
|
||||
// Clipboard Library
|
||||
new Clipboard($("#btn_shorten_url").get(0));
|
||||
new ClipboardJS($("#btn_shorten_url").get(0));
|
||||
|
||||
$("#generated_tracked_link a").click(function () {
|
||||
$("#generated_tracked_link a").text("Copied").removeClass("btn-primary").addClass("btn-success");
|
||||
|
||||
@@ -233,7 +233,7 @@ if (!$('.o_website_links_chart').length) {
|
||||
});
|
||||
|
||||
// Copy to clipboard link
|
||||
new Clipboard($('.copy-to-clipboard')[0]);
|
||||
new ClipboardJS($('.copy-to-clipboard')[0]);
|
||||
|
||||
var animating_copy = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user