[IMP] web: set visible overflow on modal for inline domain editor

When we have (inline) domain widget within a modal, user can not see
all the fields because overflow is hidden on the modals by default.
This is not ideal behavior.

With this commit, when the inline domain editor is opened with field
widget within a modal, we allow field selector to overflow by
manually setting visible overflow on the parent modal. The changes
are inspired by 'DomainSelectorDialog'.

Task ID-2480625
COM odoo/odoo#68586
This commit is contained in:
Sunil Shrimali
2021-04-21 07:49:12 +00:00
committed by Thibault Delavallée
parent d3db46f06f
commit 7c2fb9bb16
3 changed files with 49 additions and 0 deletions
@@ -3321,6 +3321,16 @@ var FieldDomain = AbstractField.extend({
this._setState();
},
/**
* We use the on_attach_callback hook here when widget is attached to the DOM, so that
* the inline 'DomainSelector' widget allows field selector to overflow if widget is
* attached within a modal.
*/
on_attach_callback() {
if (this.domainSelector && !this.inDialog) {
this.domainSelector.on_attach_callback();
}
},
//--------------------------------------------------------------------------
// Public
@@ -477,6 +477,16 @@ var DomainSelector = DomainTree.extend({
}
});
},
/**
* If 'DomainSelector' is attached within modal, the modal should have
* visible overflow to allow user to see fields drop-down.
*/
on_attach_callback() {
let $modalBodyEl = this.$el.closest('.modal-body');
if ($modalBodyEl.length !== 0) {
$modalBodyEl.css('overflow', 'visible');
}
},
//--------------------------------------------------------------------------
// Public
@@ -244,6 +244,35 @@ QUnit.module('DomainSelector', {
domainSelector.destroy();
});
QUnit.test("inline domain editor in modal", async function (assert) {
assert.expect(1);
const actions = [
{
id: 5,
name: "Partner Form",
res_model: "partner",
target: "new",
type: "ir.actions.act_window",
views: [["view_ref", "form"]],
},
];
const actionManager = await testUtils.createActionManager({
actions,
archs: {
"partner,view_ref,form": `
<form>
<field name="foo" string="Domain" widget="domain" options="{'model': 'partner'}"/>
</form>
`,
},
data: this.data,
});
await actionManager.doAction(5);
assert.strictEqual(document.querySelector('div[name="foo"]').closest('.modal-body').style.overflow,
'visible', "modal should have visible overflow if there is inline domain field widget");
actionManager.destroy();
});
});
});
});