-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] action button: use nextProps instead of this.props
In the `onWillUpdateProps` of the action button component, we used this.props instead of nextProps, which is very wrong. closes #5308 Task: 0 X-original-commit: ad2ae1b Signed-off-by: Vincent Schippefilt (vsc) <[email protected]> Signed-off-by: Adrien Minne (adrm) <[email protected]>
- Loading branch information
1 parent
70cb0f5
commit fc717b3
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, xml } from "@odoo/owl"; | ||
import { ActionSpec } from "../src/actions/action"; | ||
import { ActionButton } from "../src/components/action_button/action_button"; | ||
import { SpreadsheetChildEnv } from "../src/types"; | ||
import { mountComponent, nextTick } from "./test_helpers/helpers"; | ||
|
||
interface ParentProps { | ||
getAction: () => ActionSpec; | ||
} | ||
|
||
class Parent extends Component<ParentProps, SpreadsheetChildEnv> { | ||
static components = { ActionButton }; | ||
static template = xml/*xml*/ ` | ||
<ActionButton action="props.getAction()"/> | ||
`; | ||
} | ||
|
||
test("ActionButton is updated when its props are updated", async () => { | ||
let action = { isActive: () => true, name: "TestAction" }; | ||
const { parent, fixture } = await mountComponent(Parent, { props: { getAction: () => action } }); | ||
const actionButton = fixture.querySelector(".o-menu-item-button")!; | ||
expect(actionButton.classList).toContain("active"); | ||
|
||
action = { isActive: () => false, name: "TestAction" }; | ||
parent.render(true); | ||
await nextTick(); | ||
expect(actionButton.classList).not.toContain("active"); | ||
}); |