From e6730c6e928587cd7438340cc101c57fee34220b Mon Sep 17 00:00:00 2001 From: Parth Choksi Date: Fri, 29 Nov 2019 12:18:47 +0000 Subject: [IMP] web: better positionning of daterangepicker Before this commit, the daterangepicker always opened below the input, even when there was not enough space to display it. Moreover, when the user scrolled while the picker was opened, it wasn't stucked to the input, so the picker was displayed at a random position after the scroll. With this commit, we compute the available space above the picker when opening it, and if there is enough space, we display it above, otherwise, we display it below. Moreover, we automatically close the picker when the user scrolls. task-2117229 closes odoo/odoo#42161 Signed-off-by: Aaron Bohy (aab) Co-authored-by: Mohammed Shekha --- .../web/static/tests/fields/basic_fields_tests.js | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 7af27167e4c..5f537db41eb 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -3325,6 +3325,35 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('daterangepicker should disappear on scrolling outside of it', async function (assert) { + assert.expect(2); + + this.data.partner.fields.datetime_end = {string: 'Datetime End', type: 'datetime'}; + this.data.partner.records[0].datetime_end = '2017-03-13 00:00:00'; + + const form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: ` +
+ + + `, + res_id: 1, + }); + + await testUtils.form.clickEdit(form); + await testUtils.dom.click(form.$('.o_field_date_range:first')); + + assert.isVisible($('.daterangepicker:first'), "date range picker should be opened"); + + form.el.dispatchEvent(new Event('scroll')); + assert.isNotVisible($('.daterangepicker:first'), "date range picker should be closed"); + + form.destroy(); + }); + QUnit.module('FieldDate'); QUnit.test('date field: toggle datepicker [REQUIRE FOCUS]', async function (assert) { -- cgit v1.2.3