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

Listbox Examples: Update scrolling of listbox item with focus into view when page is magnified #2622

Merged
merged 62 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a713420
updated listbox example to fix focus visibility issues and update cod…
jongund Feb 17, 2023
f0b72f4
fixed spelling errors
jongund Feb 17, 2023
0c60ea7
udpate
jongund Feb 17, 2023
ee6be16
updated documentation of keyup and keydown commands
jongund Feb 21, 2023
5b2831d
fixed bug in rearrangable listbox
jongund Mar 1, 2023
e17add6
Merge branch 'main' into bugfix/issue-2545
jongund Mar 1, 2023
fb4bfa8
restored fiel that should not have been changed
jongund Mar 1, 2023
45dcfb6
restored file that should not have been changed
jongund Mar 2, 2023
ba970a3
updated code to remove uneeded code
jongund Mar 2, 2023
de0a3d0
added global listbox to eslint config
jongund Mar 7, 2023
80b4b36
Merge remote-tracking branch 'origin/main' into bugfix/issue-2545
mcking65 Mar 7, 2023
ec4dd4e
Satisfy linter
jugglinmike Mar 7, 2023
ab6c110
added ignore use before define
jongund Mar 8, 2023
e97a6b9
added ignore use before define
jongund Mar 8, 2023
7da18fd
updated eslint disable comments
jongund Mar 8, 2023
baae79b
Merge branch 'bugfix/issue-2545' into bugfix/issue-2545-more
aleenaloves Mar 9, 2023
551c068
Merge pull request #2642 from bocoup/bugfix/issue-2545-more
jongund Mar 14, 2023
a9fb0f4
removed eslint ignore comments
jongund Mar 14, 2023
b47e116
update strict definition
jongund Mar 14, 2023
87ddc11
fixed spelling error
jongund Mar 14, 2023
49f8bca
fixed bug with keyboard shortcut not scrolling focused item into view
jongund Apr 11, 2023
100aa42
Merge remote-tracking branch 'origin/main' into bugfix/issue-2545
mcking65 Apr 16, 2023
224e635
match section id conventions, change ol to ul
mcking65 Apr 25, 2023
319d14b
remove redundant and inaccurate information from accessibility features
mcking65 Apr 25, 2023
6394905
added aria-hidden to checkmark
jongund Apr 25, 2023
8afc844
updated scrollable and group listboxes
jongund Apr 25, 2023
b89d175
Move notes into a section and fix grammar errors.
mcking65 Apr 26, 2023
3273f93
Remove unnecessary link to utils.js from source code section.
mcking65 Apr 26, 2023
8638fca
Remove unnecessary link to utils.js in source code documentation section
mcking65 Apr 26, 2023
0d3c334
Change quote char entities to quote characters
mcking65 Apr 26, 2023
439f31a
change ol to ul where appropriate
mcking65 Apr 26, 2023
5a9b734
fixed aria-hidden bug
jongund Apr 26, 2023
d0f35aa
Merge branch 'bugfix/issue-2545' of github.com:w3c/aria-practices int…
jongund Apr 26, 2023
5b7eeb7
Add activedescendant note above keyboard documentation table
mcking65 Apr 26, 2023
46db1ac
Add activedescendant note above keyboard documentation table
mcking65 Apr 26, 2023
ec3540b
Add activedescendant note above keyboard documentation table
mcking65 Apr 26, 2023
9374333
Make activedescendant documentation in states and props table consist…
mcking65 Apr 26, 2023
ac078da
Move documentation from notes sections into APG template format
mcking65 Apr 26, 2023
2ded795
Remove redundant notes section content
mcking65 Apr 26, 2023
80c37fd
Editorial revision to accessibility features documentation of aria-ac…
mcking65 Apr 26, 2023
6d4508a
Change quote entities to quot characters
mcking65 Apr 26, 2023
d6dd990
Add tab key documentation
mcking65 Apr 26, 2023
5e69a63
Update accessibility features docs, remove utils.js link
mcking65 Apr 26, 2023
b6e3141
Change quote entities to quote characters
mcking65 Apr 26, 2023
6ac7780
Change quote entities to quote characters
mcking65 Apr 26, 2023
ff7ae0b
Update accessibility features documentation and remove link to utils.js
mcking65 Apr 26, 2023
6983e65
added aria-hidden to button character entities
jongund Apr 26, 2023
be4ce62
Merge branch 'bugfix/issue-2545' of github.com:w3c/aria-practices int…
jongund Apr 26, 2023
a2a9460
fixed regresion test:
jongund Apr 26, 2023
4f4c176
fixed bug
jongund Apr 26, 2023
35d6a04
updated documentation
jongund Apr 26, 2023
f4d2e5c
fixed keyboard bugs in toolbar
jongund Apr 27, 2023
accf5e2
Update content/patterns/listbox/examples/listbox-rearrangeable.html
jongund Apr 27, 2023
4e7a681
Fix tense of 'focus' as suggested by Howard
mcking65 Apr 27, 2023
da7a5e4
Add keyboard documentation for printable characters that perform type…
mcking65 Apr 28, 2023
38323e3
fixes checkbox issue
jongund Jul 11, 2023
a53878e
Merge remote-tracking branch 'origin/main' into bugfix/issue-2545
mcking65 Jul 24, 2023
60f3d6d
Merge remote-tracking branch 'origin/main' into bugfix/issue-2545
mcking65 Jul 25, 2023
9452228
fixed regression bug
jongund Jul 26, 2023
7e78c2c
Merge branch 'bugfix/issue-2545' of github.com:w3c/aria-practices int…
jongund Jul 26, 2023
d113845
fixed regression bug
jongund Jul 26, 2023
31759c2
remove superfluous default from switch per suggestion from Mike
mcking65 Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions content/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<td>
<ul>
<li><a href="../patterns/button/examples/button_idl.html">Button (IDL Version)</a></li>
<li><a href="../patterns/listbox/examples/listbox-grouped.html">Listbox with Grouped Options</a></li>
<li><a href="../patterns/listbox/examples/listbox-rearrangeable.html">Listboxes with Rearrangeable Options</a></li>
<li><a href="../patterns/listbox/examples/listbox-scrollable.html">Scrollable Listbox</a></li>
<li><a href="../patterns/menubar/examples/menubar-editor.html">Editor Menubar</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="../patterns/slider-multithumb/examples/slider-multithumb.html">Horizontal Multi-Thumb Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="../patterns/slider/examples/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
Expand Down
29 changes: 18 additions & 11 deletions content/patterns/listbox/examples/css/listbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,30 @@
[role="option"] {
position: relative;
display: block;
padding: 0 1em 0 1.5em;
margin: 2px;
padding: 2px 1em 2px 1.5em;
line-height: 1.8em;
cursor: pointer;
}

[role="option"].focused {
[role="listbox"]:focus [role="option"].focused {
background: #bde4ff;
}

[role="option"][aria-selected="true"]::before {
[role="listbox"]:focus [role="option"].focused,
[role="option"]:hover {
outline: 2px solid currentcolor;
}

.move-right-btn span.checkmark::after {
content: " →";
}

.move-left-btn span.checkmark::before {
content: "← ";
}

[role="option"][aria-selected="true"] span.checkmark::before {
position: absolute;
left: 0.5em;
content: "✓";
Expand Down Expand Up @@ -120,14 +135,6 @@ button[aria-disabled="true"] {
opacity: 0.5;
}

.move-right-btn::after {
content: " →";
}

.move-left-btn::before {
content: "← ";
}

.annotate {
color: #366ed4;
font-style: italic;
Expand Down
124 changes: 67 additions & 57 deletions content/patterns/listbox/examples/js/listbox-collapsible.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
/*
* This content is licensed according to the W3C Software License at
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/

'use strict';

/**
* @namespace aria
* @description
* The aria namespace is used to support sharing class definitions between example files
* without causing eslint errors for undefined classes
*/
var aria = aria || {};

/**
* ARIA Collapsible Dropdown Listbox Example
*
Expand All @@ -7,70 +21,66 @@
*/

window.addEventListener('load', function () {
var button = document.getElementById('exp_button');
var exListbox = new aria.Listbox(document.getElementById('exp_elem_list'));
new aria.ListboxButton(button, exListbox);
const button = document.getElementById('exp_button');
const exListbox = new aria.Listbox(document.getElementById('exp_elem_list'));
new ListboxButton(button, exListbox);
});

var aria = aria || {};

aria.ListboxButton = function (button, listbox) {
this.button = button;
this.listbox = listbox;
this.registerEvents();
};

aria.ListboxButton.prototype.registerEvents = function () {
this.button.addEventListener('click', this.showListbox.bind(this));
this.button.addEventListener('keyup', this.checkShow.bind(this));
this.listbox.listboxNode.addEventListener(
'blur',
this.hideListbox.bind(this)
);
this.listbox.listboxNode.addEventListener(
'keydown',
this.checkHide.bind(this)
);
this.listbox.setHandleFocusChange(this.onFocusChange.bind(this));
};

aria.ListboxButton.prototype.checkShow = function (evt) {
var key = evt.which || evt.keyCode;
class ListboxButton {
constructor(button, listbox) {
this.button = button;
this.listbox = listbox;
this.registerEvents();
}

switch (key) {
case aria.KeyCode.UP:
case aria.KeyCode.DOWN:
evt.preventDefault();
this.showListbox();
this.listbox.checkKeyPress(evt);
break;
registerEvents() {
this.button.addEventListener('click', this.showListbox.bind(this));
this.button.addEventListener('keyup', this.checkShow.bind(this));
this.listbox.listboxNode.addEventListener(
'blur',
this.hideListbox.bind(this)
);
this.listbox.listboxNode.addEventListener(
'keydown',
this.checkHide.bind(this)
);
this.listbox.setHandleFocusChange(this.onFocusChange.bind(this));
}
};

aria.ListboxButton.prototype.checkHide = function (evt) {
var key = evt.which || evt.keyCode;
checkShow(evt) {
switch (evt.key) {
case 'ArrowUp':
case 'ArrowDown':
evt.preventDefault();
this.showListbox();
this.listbox.checkKeyPress(evt);
break;
}
}

switch (key) {
case aria.KeyCode.RETURN:
case aria.KeyCode.ESC:
evt.preventDefault();
this.hideListbox();
this.button.focus();
break;
checkHide(evt) {
switch (evt.key) {
case 'Enter':
case 'Escape':
evt.preventDefault();
this.hideListbox();
this.button.focus();
break;
}
}
};

aria.ListboxButton.prototype.showListbox = function () {
aria.Utils.removeClass(this.listbox.listboxNode, 'hidden');
this.button.setAttribute('aria-expanded', 'true');
this.listbox.listboxNode.focus();
};
showListbox() {
this.listbox.listboxNode.classList.remove('hidden');
this.button.setAttribute('aria-expanded', 'true');
this.listbox.listboxNode.focus();
}

aria.ListboxButton.prototype.hideListbox = function () {
aria.Utils.addClass(this.listbox.listboxNode, 'hidden');
this.button.removeAttribute('aria-expanded');
};
hideListbox() {
this.listbox.listboxNode.classList.add('hidden');
this.button.removeAttribute('aria-expanded');
}

aria.ListboxButton.prototype.onFocusChange = function (focusedItem) {
this.button.innerText = focusedItem.innerText;
};
onFocusChange(focusedItem) {
this.button.innerText = focusedItem.innerText;
}
}
10 changes: 8 additions & 2 deletions content/patterns/listbox/examples/js/listbox-rearrangeable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/

/* global aria */

'use strict';

/**
* @namespace aria
* @description
* The aria namespace is used to support sharing class definitions between example files
* without causing eslint errors for undefined classes
*/
var aria = aria || {};

/**
* ARIA Listbox Examples
*
Expand Down
10 changes: 8 additions & 2 deletions content/patterns/listbox/examples/js/listbox-scrollable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/

/* global aria */

'use strict';

/**
* @namespace aria
* @description
* The aria namespace is used to support sharing class definitions between example files
* without causing eslint errors for undefined classes
*/
var aria = aria || {};

/**
* ARIA Scrollable Listbox Example
*
Expand Down