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

File Viewer Tree Examples: Add aria-selected #1869

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a8ebc01
Set aria selected to active tree view item
kdoberst Apr 23, 2021
2d96a4b
Apply suggestions from code review
zcorpan Oct 29, 2021
e93dbfd
Add aria-selected=false to all treeitems
zcorpan Nov 2, 2021
9987e3f
Add aria-selected documentation and tests (WIP, test is failing)
zcorpan Nov 3, 2021
fbaacd6
Update the implementation to set aria-selected onclick and fix tests
zcorpan Nov 3, 2021
63f4875
added "My Documents" label for "File Viewer" heading
howard-e Nov 10, 2021
907999f
stop ENTER from expanding/collapsing tree; support selecting with ENTER
howard-e Nov 10, 2021
16bad82
revised treeview-1a regression tests
howard-e Nov 10, 2021
a052ded
revised treeview-1b regression tests
howard-e Nov 10, 2021
c680fd8
revised regression tests
howard-e Nov 10, 2021
694b123
visual indicator
howard-e Nov 10, 2021
05c93b6
remove transparent border
howard-e Nov 10, 2021
8519342
aligning visual indicator more with treeview-navigation example
howard-e Nov 10, 2021
d7af925
Merge remote-tracking branch 'origin/main' into pull-1869
mcking65 Nov 12, 2021
bfa789f
Merge remote-tracking branch 'origin/main' into pull-1869
mcking65 Nov 13, 2021
356bcc5
Improve intro
mcking65 Nov 13, 2021
4b337c7
Improve intro
mcking65 Nov 13, 2021
cbb4486
editorial revisions to keyboard documentation
mcking65 Nov 13, 2021
3dc9bfa
Update states and properties documentation
mcking65 Nov 13, 2021
72d3334
Replace named entity for quote with quote char inside code tag elements
mcking65 Nov 13, 2021
58d6da7
Change IDREF to ID_REFERENCE
mcking65 Nov 13, 2021
8fa0ee6
fix white space
mcking65 Nov 13, 2021
583e944
Remove aria-label from h3 element
mcking65 Nov 13, 2021
8d649b5
Add info about selection not following focus to kb documentation section
mcking65 Nov 13, 2021
f623ddb
File Viewer Tree Example: fix for broken icons on declared properties…
howard-e Nov 15, 2021
fa2b72c
File Viewer Tree Example: behavior of SPACE changed to be the same as…
howard-e Nov 15, 2021
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
2 changes: 2 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="listbox/listbox-rearrangeable.html">Listboxes with Rearrangeable Options</a></li>
<li><a href="tabs/tabs-1/tabs.html">Tabs with Automatic Activation</a></li>
<li><a href="tabs/tabs-2/tabs.html">Tabs with Manual Activation</a></li>
<li><a href="treeview/treeview-1/treeview-1a.html">File Directory Treeview Using Computed Properties</a></li>
<li><a href="treeview/treeview-1/treeview-1b.html">File Directory Treeview Using Declared Properties</a></li>
</ul>
</td>
</tr>
Expand Down
9 changes: 9 additions & 0 deletions examples/treeview/treeview-1/js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var Tree = function (node) {

this.firstTreeitem = null;
this.lastTreeitem = null;
this.selectedItem = null;
};

Tree.prototype.init = function () {
Expand Down Expand Up @@ -87,6 +88,14 @@ Tree.prototype.init = function () {
this.firstTreeitem.domNode.tabIndex = 0;
};

Tree.prototype.setSelectedToItem = function (treeitem) {
if (this.selectedItem) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of mirroring how setFocusToItem is implemented with something like:

  for (let i = 0; i < this.treeitems.length; i++) {
    const ti = this.treeitems[i];
    if (ti === treeitem) {
      ti.domNode.setAttribute('aria-selected', 'true');
    } else {
      ti.domNode.removeAttribute('aria-selected');
    }
  }

this.selectedItem.domNode.setAttribute('aria-selected', 'false');
}
treeitem.domNode.setAttribute('aria-selected', 'true');
this.selectedItem = treeitem;
};

Tree.prototype.setFocusToItem = function (treeitem) {
for (var i = 0; i < this.treeitems.length; i++) {
var ti = this.treeitems[i];
Expand Down
1 change: 1 addition & 0 deletions examples/treeview/treeview-1/js/treeitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Treeitem.prototype.handleClick = function (event) {
} else {
this.tree.setFocusToItem(this);
}
this.tree.setSelectedToItem(this);
};

Treeitem.prototype.handleFocus = function () {
Expand Down
123 changes: 78 additions & 45 deletions examples/treeview/treeview-1/treeview-1a.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,189 +57,200 @@ <h3 id="tree_label">
</h3>
<ul role="tree" aria-labelledby="tree_label">
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
Projects
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-1.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-2.docx
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
Project 3
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-3A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-3B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-3C.docx
</li>
</ul>
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-4.docx
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
Project 5
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-5A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-5B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-5C.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-5D.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-5E.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
project-5F.docx
</li>
</ul>
</li>
</ul>
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
Reports
</span>
<ul role="group">
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
report-1
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-1A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-1B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-1C.docx
</li>
</ul>
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
report-2
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-2A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-2B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-2C.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-2D.docx
</li>
</ul>
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
report-3
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-3A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-3B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-3C.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
report-3D.docx
</li>
</ul>
</li>
</ul>
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
Letters
</span>
<ul role="group">
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
letter-1
</span>
<ul>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-1A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-1B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-1C.docx
</li>
</ul>
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
letter-2
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-2A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-2B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-2C.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-2D.docx
</li>
</ul>
</li>
<li role="treeitem"
aria-expanded="false">
aria-expanded="false"
aria-selected="false">
<span>
letter-3
</span>
<ul role="group">
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-3A.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-3B.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-3C.docx
</li>
<li role="treeitem" class="doc">
<li role="treeitem" aria-selected="false" class="doc">
letter-3D.docx
</li>
</ul>
Expand Down Expand Up @@ -451,6 +462,28 @@ <h2 id="rps_label">Role, Property, State, and Tabindex Attributes</h2>
</ul>
</td>
</tr>
<tr data-test-id="treeitem-aria-selected">
<td></td>
<th scope="row"><code>aria-selected=&quot;false&quot;</code></th>
<td><code>li</code></td>
<td>
<ul>
<li>Applied to <code>treeitem</code> elements.</li>
<li>Indicates the file or folder for the item is not currently selected.</li>
</ul>
</td>
</tr>
<tr data-test-id="treeitem-aria-selected">
<td></td>
<th scope="row"><code>aria-selected=&quot;true&quot;</code></th>
<td><code>li</code></td>
<td>
<ul>
<li>Applied to <code>treeitem</code> elements.</li>
<li>Indicates the file or folder for the item is currently selected.</li>
</ul>
</td>
</tr>
<tr data-test-id="group-role">
<th scope="row"><code>group</code></th>
<td></td>
Expand Down
Loading