mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] portal: add support for .closest modifier
It is sometimes useful in practice to be able to configure the portal so that it looks for a target as close as possible as the portal location. For example, in odoo, a portal may be set up in a form view that should target the current form view. But if the form view itself is in a dialog, it may fail, because it may find a valid target in the form view that is located underneath. With this commit, we add a .closest modifier to the `t-portal` directive.
This commit is contained in:
@@ -1998,6 +1998,7 @@ describe("qweb parser", () => {
|
||||
test("t-portal", async () => {
|
||||
expect(parse(`<t t-portal="target">Content</t>`)).toEqual({
|
||||
type: ASTType.TPortal,
|
||||
isClosest: false,
|
||||
target: "target",
|
||||
content: { type: ASTType.Text, value: "Content" },
|
||||
});
|
||||
@@ -2008,6 +2009,7 @@ describe("qweb parser", () => {
|
||||
condition: "condition",
|
||||
content: {
|
||||
content: { type: ASTType.Text, value: "Content" },
|
||||
isClosest: false,
|
||||
target: "target",
|
||||
type: ASTType.TPortal,
|
||||
},
|
||||
@@ -2016,4 +2018,13 @@ describe("qweb parser", () => {
|
||||
type: ASTType.TIf,
|
||||
});
|
||||
});
|
||||
|
||||
test("t-portal with .closest", async () => {
|
||||
expect(parse(`<t t-portal.closest="target">Content</t>`)).toEqual({
|
||||
type: ASTType.TPortal,
|
||||
isClosest: true,
|
||||
target: "target",
|
||||
content: { type: ASTType.Text, value: "Content" },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user