From 16eb36ff45bec31cfb98865b739c34e0a513a02f Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 16 Jul 2015 15:24:02 +0200 Subject: [IMP] web: use a classname to show/hide widgets The problem of $el.show()/hide() is that calling show() on a jQuery element on which there is no display rule in the stylesheet automatically sets 'display: block'. However, when a jQuery element is not yet in the DOM, the rules defined on it are not yet applied, meaning that calling show() will set its display to block (in inline style), even if there is different a css rule (e.g. 'dislay: flex'). As the inline style takes the priority over the stylesheet, the correct display won't be applied, even when the widget will be appended in the DOM, resulting in a possibly broken layout. --- addons/web/static/src/js/framework/widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/framework') diff --git a/addons/web/static/src/js/framework/widget.js b/addons/web/static/src/js/framework/widget.js index 199568b727f..70f48caa261 100644 --- a/addons/web/static/src/js/framework/widget.js +++ b/addons/web/static/src/js/framework/widget.js @@ -347,10 +347,10 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, { return this.$el.find(selector); }, do_show: function () { - this.$el.show(); + this.$el.removeClass('o_hidden'); }, do_hide: function () { - this.$el.hide(); + this.$el.addClass('o_hidden'); }, /** * Proxies a method of the object, in order to keep the right ``this`` on -- cgit v1.2.3