diff options
| author | Parth Choksi <pch@odoo.com> | 2019-11-29 12:18:47 +0000 |
|---|---|---|
| committer | aab-odoo <aab@odoo.com> | 2020-02-27 07:51:43 +0000 |
| commit | e6730c6e928587cd7438340cc101c57fee34220b (patch) | |
| tree | 1daef35c130f5ee1fa8c004edce7e599cfe0756f /addons/web/static/tests/fields | |
| parent | ae15f89f73cffaebd20ba74b9c20ad641a1ea5e4 (diff) | |
[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) <aab@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'addons/web/static/tests/fields')
| -rw-r--r-- | addons/web/static/tests/fields/basic_fields_tests.js | 29 |
1 files changed, 29 insertions, 0 deletions
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: ` + <form> + <field name="datetime" widget="daterange" options="{'related_end_date': 'datetime_end'}"/> + <field name="datetime_end" widget="daterange" options="{'related_start_date': 'datetime'}"/> + </form>`, + 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) { |
