[FIX] web: form: keep data-hotkey attribute on buttons
Before this commit, the data-hotkey attribute set on button nodes in form views was ignored. This commit re-introduces the feature, enabling the keynav on those buttons. closes odoo/odoo#100563 Signed-off-by: Georis François (fge) <fge@odoo.com>
This commit is contained in:
@@ -130,6 +130,7 @@ ViewButton.props = [
|
||||
"className?",
|
||||
"context?",
|
||||
"clickParams?",
|
||||
"hotkey?",
|
||||
"icon?",
|
||||
"defaultRank?",
|
||||
"disabled?",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
t-att-href="props.tag === 'a' and '#'"
|
||||
t-att-style="props.style"
|
||||
t-att-type="clickParams.type"
|
||||
t-att-data-hotkey="props.hotkey"
|
||||
t-att-data-tooltip-template="hasBigTooltip ? 'views.ViewButtonTooltip' : false"
|
||||
t-att-data-tooltip-info="hasBigTooltip ? tooltip : false"
|
||||
t-att-data-tooltip="hasSmallToolTip ? props.title : false"
|
||||
|
||||
@@ -345,6 +345,9 @@ export class ViewCompiler {
|
||||
button.setAttribute(name, toStringExpression(value));
|
||||
}
|
||||
}
|
||||
if (el.hasAttribute("data-hotkey")) {
|
||||
button.setAttribute("hotkey", toStringExpression(el.getAttribute("data-hotkey")));
|
||||
}
|
||||
|
||||
button.setAttribute("clickParams", JSON.stringify(clickParams));
|
||||
combineAttributes(
|
||||
|
||||
@@ -3014,6 +3014,35 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.verifySteps(["get_views", "onchange", "create", "read", "execute_action", "read"]);
|
||||
});
|
||||
|
||||
QUnit.test("buttons with data-hotkey attribute", async function (assert) {
|
||||
const mockedActionService = {
|
||||
start() {
|
||||
return {
|
||||
doActionButton(params) {
|
||||
assert.step(params.name);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
serviceRegistry.add("action", mockedActionService, { force: true });
|
||||
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<button name="validate" string="Validate" type="object" data-hotkey="v"/>
|
||||
</form>`,
|
||||
resId: 2,
|
||||
});
|
||||
|
||||
assert.containsOnce(target, ".o_form_readonly button[data-hotkey=v]");
|
||||
triggerHotkey("alt+v");
|
||||
await nextTick();
|
||||
assert.verifySteps(["validate"]);
|
||||
});
|
||||
|
||||
QUnit.test("change and save char", async function (assert) {
|
||||
assert.expect(6);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user