From c9a2b9a00a5f73c20892d74575b1b4c4a3c4cd5c Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Fri, 29 Jun 2018 15:46:26 +0200 Subject: [FIX] web: keep searchview floating content on update In a search view, write text in the input, then hit enter to select the facet. Before this commit, the search view was detached and then reattached when the control panel was refreshed. This led to loosing the focus momentarily and erasing any supplementary input one might have typed *during* the rpc call. After this commit, if the search view is the same as before, we don't detach it in the first place. Thus, the input is conserved in this situation. OPW 1861941 OPW 185614t closes #25546 --- addons/web/static/src/js/chrome/control_panel.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome/control_panel.js b/addons/web/static/src/js/chrome/control_panel.js index 4104f37bd3e..0913b574a3d 100644 --- a/addons/web/static/src/js/chrome/control_panel.js +++ b/addons/web/static/src/js/chrome/control_panel.js @@ -148,15 +148,25 @@ var ControlPanel = Widget.extend({ } // Detach control_panel old content and attach new elements + var toDetach = this.nodes; + if (status.searchview && this.searchview === status.searchview) { + // If the searchview is the same as before, don't detach it s.t. + // we don't loose any floating content, nor the focus + toDetach = _.omit(toDetach, '$searchview'); + new_cp_content = _.omit(new_cp_content, '$searchview'); + } if (options.clear) { - this._detach_content(this.nodes); + this._detach_content(toDetach); // Show the searchview buttons area, which might have been hidden by // the searchview, as client actions may insert elements into it this.nodes.$searchview_buttons.show(); } else { - this._detach_content(_.pick(this.nodes, _.keys(new_cp_content))); + this._detach_content(_.pick(toDetach, _.keys(new_cp_content))); } this._attach_content(new_cp_content); + if (options.clear || status.searchview) { + this.searchview = status.searchview; + } // Update the searchview and switch buttons if (status.searchview || options.clear) { -- cgit v1.2.3