[FIX] web: time range menu flickering

The search view always instantiates a time range menu but hides it
when it is not used.

Now, when the time range menu is not used, every time the search view
facets are rendered, the time range menu is also rendered entirely
and becomes visible shortly before being hide again. This caused
a bad screen flickering.

This commit fixes that problem by avoidind the unnecessary rendering of
the time range menu.
This commit is contained in:
Mathieu Duckerts-Antoine
2018-08-17 10:26:31 +02:00
parent c995aa2cfd
commit 3ec6624754
2 changed files with 32 additions and 3 deletions
@@ -445,9 +445,9 @@ var SearchView = Widget.extend({
self.timeRangeMenu = self._createTimeRangeMenu();
menu_defs.push(self.timeRangeMenu.prependTo($buttons));
self.timeRangeMenu.do_hide();
var display = self.options.disableTimeRangeMenu !== undefined &&
self.displayedTimeRangeMenu = self.options.disableTimeRangeMenu !== undefined &&
!self.options.disableTimeRangeMenu;
self.displayTimeRangeMenu(display);
self.displayTimeRangeMenu(self.displayedTimeRangeMenu);
if (!self.options.disable_groupby) {
self.groupby_menu = self._createGroupByMenu();
menu_defs.push(self.groupby_menu.prependTo($buttons));
@@ -736,7 +736,7 @@ var SearchView = Widget.extend({
}
if (self.filters_menu) {
self.filters_menu.updateItemsStatus(activeItemIds.filterCategory); }
if (self.timeRangeMenu && !timeRangeMenuIsActive) {
if (self.displayedTimeRangeMenu && !timeRangeMenuIsActive) {
self.timeRangeMenu.deactivate();
}
});
@@ -635,5 +635,34 @@ QUnit.module('Search View', {
actionManager.destroy();
});
QUnit.test('time range menu stays hidden', function (assert) {
assert.expect(6);
var actionManager = createActionManager({
actions: this.actions,
archs: this.archs,
data: this.data,
});
actionManager.doAction(1);
// check that the fifth dropdown is the time range menu and is hidden
assert.ok($('.btn-group.o_dropdown').eq(4).hasClass('o_hidden'));
assert.ok($('.btn-group.o_dropdown').eq(4).children().eq(1).hasClass('o_time_range_menu'));
// check if search view has no facets
assert.strictEqual($('.o_facet_values').length, 0);
// activate groupby
$('button .fa-bars').click();
$('.o_menu_item a').eq(0).click();
// check that there is a facet
assert.strictEqual($('div.o_facet_values').length, 1);
// check that the fifth dropdown is the time range menu and is still hidden
assert.ok($('.btn-group.o_dropdown').eq(4).hasClass('o_hidden'));
assert.ok($('.btn-group.o_dropdown').eq(4).children().eq(1).hasClass('o_time_range_menu'));
actionManager.destroy();
});
});
});