mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] t-model takes precedence over t-on-input
With this commit, we make sure that the code for t-model is run before t-on-input event handler. This is useful to make sure that the state reflected by t-model is up-to-date. closes #1295
This commit is contained in:
committed by
Sam Degueldre
parent
9a5edb4590
commit
4a5316ced5
@@ -625,4 +625,23 @@ describe("t-model directive", () => {
|
||||
await mount(Test, fixture);
|
||||
expect(fixture.querySelector("select")!.value).toEqual("b");
|
||||
});
|
||||
|
||||
test("t-model is applied before t-on-input", async () => {
|
||||
expect.assertions(3);
|
||||
class SomeComponent extends Component {
|
||||
static template = xml`
|
||||
<div>
|
||||
<input t-model="state['text']" t-on-input="onInput"/>
|
||||
</div>
|
||||
`;
|
||||
state = useState({ text: "", other: "" });
|
||||
onInput(ev: InputEvent) {
|
||||
expect(this.state.text).toBe("Beam me up, Scotty");
|
||||
expect((ev.target as HTMLInputElement).value).toBe("Beam me up, Scotty");
|
||||
}
|
||||
}
|
||||
await mount(SomeComponent, fixture);
|
||||
const input = fixture.querySelector("input")!;
|
||||
await editInput(input, "Beam me up, Scotty");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user