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

WICKET-7131 Improved accessibility and screen reader support #1034

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
showAutoComplete();
}
render(true, false);
jqEvent.preventDefault();
}

break;
Expand All @@ -153,6 +154,7 @@
render(true, false);
showAutoComplete();
}
jqEvent.preventDefault();
}

break;
Expand Down Expand Up @@ -243,7 +245,7 @@
{
// Remove the autocompletion menu if still present from
// a previous call. This is required to properly register
// the mouse event handler again
// the mouse event handler again
var choiceDiv=document.getElementById(getMenuId());
if (choiceDiv !== null) {
choiceDiv.parentNode.parentNode.removeChild(choiceDiv.parentNode);
Expand Down Expand Up @@ -325,7 +327,6 @@
container.appendChild(choiceDiv);
choiceDiv.id=getMenuId();
choiceDiv.className = "wicket-aa";
choiceDiv.ariaLive = "polite";
}


Expand Down Expand Up @@ -404,6 +405,9 @@
var container = getAutocompleteContainer();
var index=getOffsetParentZIndex(ajaxAttributes.c);
container.show();

input.setAttribute("aria-expanded", "true");

if (!isNaN(Number(index))) {
container.style.zIndex=(Number(index)+1);
}
Expand Down Expand Up @@ -441,6 +445,13 @@

function hideAutoComplete(){
hideAutoCompleteTimer = undefined;

var input = Wicket.$(ajaxAttributes.c);
if (input) {
input.setAttribute("aria-expanded", "false");
input.removeAttribute("aria-activedescendant");
}

visible = 0;
setSelected(-1);

Expand Down Expand Up @@ -612,6 +623,7 @@
selChSinceLastRender = true; // selected item will not have selected style until rendrered
}
element.innerHTML=resp;
element.firstChild.role = "listbox"
var selectableElements = getSelectableElements();
if (selectableElements) {
elementCount=selectableElements.length;
Expand Down Expand Up @@ -659,6 +671,11 @@
node.onclick = clickFunc;
node.onmouseover = mouseOverFunc;
node.onmousedown = mouseDownFunc;
node.role = "option";
node.id = getMenuId() + '-item-' + i;
node.setAttribute("tabindex", -1);
node.setAttribute("aria-posinset", i + 1)
node.setAttribute("aria-setsize", elementCount)
}
} else {
elementCount=0;
Expand Down Expand Up @@ -754,16 +771,26 @@
var node=getSelectableElement(0);
var re = /\bselected\b/gi;
var sizeAffected = false;
var input=Wicket.$(ajaxAttributes.c);

for(var i=0;i<elementCount;i++)
{
var origClassNames = node.className;
var classNames = origClassNames.replace(re, "");

if(selected===i){
classNames += " selected";
node.setAttribute("aria-selected", "true");
input.setAttribute("aria-activedescendant", node.id);

if (adjustScroll) {
adjustScrollOffset(menu.parentNode, node);
}
}
else {
node.setAttribute("aria-selected", "false");
}

if (classNames !== origClassNames) {
node.className = classNames;
}
Expand Down
Loading