Skip to content

Commit

Permalink
[FIX] web: list view's optional fields dropdown clipping in Firefox
Browse files Browse the repository at this point in the history
Note: as we don't have a way to have a relative selector in `t-portal`,
a unique class had to be added to the ListRenderer. The point is to
target the parent list instead of the first in the page (cf.
odoo/owl#1428).

References:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1887116
- https://bugs.webkit.org/show_bug.cgi?id=160953
  • Loading branch information
pparidans committed Apr 4, 2024
1 parent daacfb6 commit 91a1478
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
24 changes: 23 additions & 1 deletion addons/web/static/src/views/list/list_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useBounceButton } from "@web/views/view_hook";
import { Widget } from "@web/views/widgets/widget";
import { getFormattedValue } from "../utils";
import { localization } from "@web/core/l10n/localization";
import { uniqueId } from "@web/core/utils/functions";

import {
Component,
Expand Down Expand Up @@ -72,6 +73,26 @@ function getElementToFocus(cell, index) {
return getTabableElements(cell).at(index) || cell;
}

/**
* Here be dragons. 🐉
* This is a workaround to avoid clipping issues in Firefox and Safari.
* cf. https://bugzilla.mozilla.org/show_bug.cgi?id=1887116
*/
class OptionalFieldsDropdown extends Dropdown {
static template = "web.ListRenderer.OptionalFieldsDropdown";
static props = {
...Dropdown.props,
listRendererClass: String,
};

onWindowClicked(ev) {
if (ev.target.closest(".o_optional_columns_dropdown.o-dropdown--menu")) {
return;
}
super.onWindowClicked(...arguments);
}
}

export class ListRenderer extends Component {
setup() {
this.uiService = useService("ui");
Expand Down Expand Up @@ -207,6 +228,7 @@ export class ListRenderer extends Component {
this.lastEditedCell = null;
});
this.isRTL = localization.direction === "rtl";
this.uniqueRendererClass = uniqueId("o_list_renderer_");
}

displaySaveNotification() {
Expand Down Expand Up @@ -2065,7 +2087,7 @@ ListRenderer.rowsTemplate = "web.ListRenderer.Rows";
ListRenderer.recordRowTemplate = "web.ListRenderer.RecordRow";
ListRenderer.groupRowTemplate = "web.ListRenderer.GroupRow";

ListRenderer.components = { DropdownItem, Field, ViewButton, CheckBox, Dropdown, Pager, Widget };
ListRenderer.components = { DropdownItem, Field, ViewButton, CheckBox, Dropdown: OptionalFieldsDropdown, Pager, Widget };
ListRenderer.props = [
"activeActions?",
"list",
Expand Down
9 changes: 9 additions & 0 deletions addons/web/static/src/views/list/list_renderer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<t t-name="web.ListRenderer" owl="1">
<div
class="o_list_renderer o_renderer table-responsive"
t-att-class="uniqueRendererClass"
tabindex="-1"
t-ref="root"
>
Expand Down Expand Up @@ -46,6 +47,7 @@
class="'o_optional_columns_dropdown text-center border-top-0'"
togglerClass="'btn p-0'"
skipTogglerTabbing="true"
listRendererClass="uniqueRendererClass"
position="'bottom-end'">
<t t-set-slot="toggler">
<i class="o_optional_columns_dropdown_toggle oi oi-fw oi-settings-adjust"/>
Expand Down Expand Up @@ -291,4 +293,11 @@
</tr>
</t>

<t t-name="web.ListRenderer.OptionalFieldsDropdown" t-inherit="web.Dropdown" t-inherit-mode="primary">
<xpath expr="//div[@t-if='state.open']" position="attributes">
<attribute name="t-portal">"."+props.listRendererClass</attribute>
<attribute name="class" add="o_optional_columns_dropdown" separator=" "/>
</xpath>
</t>

</templates>

0 comments on commit 91a1478

Please sign in to comment.