Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(focusables): exclude children of hidden elements #179

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/core/makeup-expander/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/core/makeup-expander/index.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/core/makeup-focusables/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h1>makeup-focusables demo</h1>
<button id="appender1">Append Sequential</button>
<button id="appender2">Append Non-Sequential</button>
<button id="appender3">Append Hidden</button>
<button id="appender4">Append Nested Hidden</button>

<ul id="list"></ul>
</main>
Expand Down
10 changes: 8 additions & 2 deletions docs/core/makeup-focusables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,28 @@ const listEl = document.getElementById("list");
const appender1 = document.getElementById("appender1");
const appender2 = document.getElementById("appender2");
const appender3 = document.getElementById("appender3");
const appender4 = document.getElementById("appender4");
const output = document.getElementById("output");

function onButtonClick(e) {
e.preventDefault();

const listItem = document.createElement("li");
listItem.innerText = `Item ${listEl.childNodes.length}`;

if (e.target.id === "appender1") {
listItem.setAttribute("tabindex", "0");
} else if (e.target.id === "appender2") {
listItem.setAttribute("tabindex", "-1");
} else {
} else if (e.target.id === "appender3") {
listItem.setAttribute("tabindex", "0");
listItem.setAttribute("hidden", "hidden");
} else {
const listItemChild = document.createElement("button");
listItem.setAttribute("hidden", "hidden");
listItem.appendChild(listItemChild);
}

listItem.innerText = `Item ${listEl.childNodes.length}`;
listEl.appendChild(listItem);

const focusableEls = focusables(listEl);
Expand All @@ -34,3 +39,4 @@ function onButtonClick(e) {
appender1.addEventListener("click", onButtonClick);
appender2.addEventListener("click", onButtonClick);
appender3.addEventListener("click", onButtonClick);
appender4.addEventListener("click", onButtonClick);
20 changes: 16 additions & 4 deletions docs/core/makeup-focusables/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/core/makeup-focusables/index.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions docs/core/makeup-keyboard-trap/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading