diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f8a535 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*.{js,ts}] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.html] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/cypress/e2e/spec.cy.ts b/cypress/e2e/spec.cy.ts index fb13f94..29d7adc 100644 --- a/cypress/e2e/spec.cy.ts +++ b/cypress/e2e/spec.cy.ts @@ -23,8 +23,13 @@ describe("focus-shift spec", () => { for (let pair of sequence) { switch (pair.eventType) { + case "click": + cy.get(pair.selector).click() + break case "focus": - cy.get(pair.selector).focus() + cy.get(pair.selector).then(($elem) => { + $elem[0].focus() + }) break default: cy.get("body") @@ -192,6 +197,28 @@ describe("focus-shift spec", () => { ]) ) + it( + "ignores contents of closed details element", + testFor("./cypress/fixtures/details.html", { className: "rows" }, [ + { eventType: "keydown", selector: "#button-1", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#summary-1", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#button-2", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#summary-1", options: keyevent({ key: "ArrowUp" }) }, + { eventType: "click", selector: "#summary-1" }, + { eventType: "focus", selector: "#summary-1" }, + { eventType: "keydown", selector: "#group-button-1", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#group-button-2", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#summary-2", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#button-2", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#summary-2", options: keyevent({ key: "ArrowUp" }) }, + { eventType: "click", selector: "#summary-2" }, + { eventType: "focus", selector: "#summary-2" }, + { eventType: "keydown", selector: "#subgroup-button-1", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#subgroup-button-2", options: keyevent({ key: "ArrowDown" }) }, + { eventType: "keydown", selector: "#button-2", options: keyevent({ key: "ArrowDown" }) } + ]) + ) + it( "allows canceling event handling", testFor("./cypress/fixtures/events.html", { className: "rows" }, [ diff --git a/cypress/fixtures/details.html b/cypress/fixtures/details.html new file mode 100644 index 0000000..59e9464 --- /dev/null +++ b/cypress/fixtures/details.html @@ -0,0 +1,30 @@ + + +
+ + + + + + + +