mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
DEV: @bind create-account actions (#17100)
DEV: @bind create-account actions Context: https://github.com/discourse/discourse/pull/16983#discussion_r894721403
This commit is contained in:
parent
275849771f
commit
bc0a37b642
|
@ -1,5 +1,6 @@
|
|||
import Component from "@ember/component";
|
||||
import cookie from "discourse/lib/cookie";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ["create-account-body"],
|
||||
|
@ -21,6 +22,7 @@ export default Component.extend({
|
|||
}
|
||||
},
|
||||
|
||||
@bind
|
||||
actionOnEnter(event) {
|
||||
if (!this.disabled && event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
|
@ -30,6 +32,7 @@ export default Component.extend({
|
|||
}
|
||||
},
|
||||
|
||||
@bind
|
||||
selectKitFocus(event) {
|
||||
const target = document.getElementById(event.target.getAttribute("for"));
|
||||
if (target?.classList.contains("select-kit")) {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import {
|
||||
acceptance,
|
||||
count,
|
||||
exists,
|
||||
query,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("Create Account - User Fields", function (needs) {
|
||||
|
@ -65,4 +66,22 @@ acceptance("Create Account - User Fields", function (needs) {
|
|||
await click(".user-field input[type=checkbox]");
|
||||
await click(".modal-footer .btn-primary");
|
||||
});
|
||||
|
||||
test("can submit with enter", async function (assert) {
|
||||
await visit("/");
|
||||
await click("header .sign-up-button");
|
||||
|
||||
await triggerKeyEvent(".modal-footer .btn-primary", "keydown", 13);
|
||||
|
||||
assert.strictEqual(
|
||||
count("#modal-alert:visible"),
|
||||
1,
|
||||
"hitting Enter triggers modal action"
|
||||
);
|
||||
assert.strictEqual(
|
||||
count(".d-modal:visible"),
|
||||
1,
|
||||
"hitting Enter does not dismiss modal due to alert error"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user