diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-06-29 15:46:26 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-07-12 13:01:05 +0200 |
| commit | c9a2b9a00a5f73c20892d74575b1b4c4a3c4cd5c (patch) | |
| tree | 7b44b763f6693514210763530211a026c4fcd053 /addons/web/static/src/js/chrome/control_panel.js | |
| parent | 2b38f271d55cbec45bfe71e1905fbb9a3428093e (diff) | |
[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
Diffstat (limited to 'addons/web/static/src/js/chrome/control_panel.js')
| -rw-r--r-- | addons/web/static/src/js/chrome/control_panel.js | 14 |
1 files changed, 12 insertions, 2 deletions
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) { |
