diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f5b7f8..aa7f25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.1.0] - April 23, 2021 + +Better digital accessibility. + ## [1.0.2] - April 19, 2021 New options for the items: diff --git a/src/JSPanel.js b/src/JSPanel.js index 36ea632..c85679f 100644 --- a/src/JSPanel.js +++ b/src/JSPanel.js @@ -119,6 +119,10 @@ class JSPanel { else { this.button.setAttribute("aria-expanded", "true"); this.panel.classList.remove("panel-hidden"); + // Digital accessibility + const all_items = this.panel.querySelectorAll("li"); + if (all_items && all_items[0]) + all_items[0].focus(); } } } @@ -182,6 +186,7 @@ class JSPanel { } else { const li = this._createEl("li"); + li.setAttribute("tabindex", "0"); if ((item.icon && !item.fontawesome_icon) || (item.icon && item.fontawesome_icon)) { const icon = this._createEl("img", { attributes: [["src", item.icon]] }); li.appendChild(icon); diff --git a/src/JSPanel.ts b/src/JSPanel.ts index e8fa19e..315951c 100644 --- a/src/JSPanel.ts +++ b/src/JSPanel.ts @@ -170,6 +170,11 @@ class JSPanel { } else { this.button.setAttribute("aria-expanded", "true"); this.panel.classList.remove("panel-hidden"); + + // Digital accessibility + + const all_items = this.panel.querySelectorAll("li"); + if (all_items && all_items[0]) all_items[0].focus(); } } } @@ -236,6 +241,7 @@ class JSPanel { return div; } else { const li = this._createEl("li"); + li.setAttribute("tabindex", "0"); if ((item.icon && !item.fontawesome_icon) || (item.icon && item.fontawesome_icon)) { const icon = this._createEl("img", { attributes: [["src", item.icon]] }); diff --git a/src/example.html b/src/example.html index 22ca55b..400313e 100644 --- a/src/example.html +++ b/src/example.html @@ -37,7 +37,6 @@ height: 55px; border-radius: 50%; border: none; - outline: none; cursor: pointer; background-color: #fff; border: 1px solid #dfe3eb; @@ -70,7 +69,7 @@

Look the button right there, here, you see it ?

{ title: "My Profile", fontawesome_icon: "far fa-user", onclick: () => console.log("clicked on profile") }, { title: "Settings", fontawesome_icon: "fas fa-cog", onclick: () => console.log("clicked on settings") }, { separator: true, }, - { title: "Close", fontawesome_icon: "far fa-window-close", className: "js-modal", attributes: [["data-modal", "#truc"]], onclick: () => console.log("clicked on close") }, + { title: "Close", fontawesome_icon: "far fa-window-close", onclick: () => console.log("clicked on close") }, ], }); diff --git a/src/panel-style.css b/src/panel-style.css index efb2de3..3fcaa41 100644 --- a/src/panel-style.css +++ b/src/panel-style.css @@ -56,6 +56,10 @@ color: var(--panel-hover-item-color, #385074); } +.jspanel li:focus { + outline: auto; +} + /* the title of the item */ .jspanel li span { pointer-events: none;