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 ariaSelected behavior #173

Merged
merged 1 commit into from
Jan 29, 2019
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onenotepicker",
"version": "3.0.9",
"version": "3.0.10",
"files": [
"dist/**/*"
],
Expand Down
4 changes: 2 additions & 2 deletions src/components/notebookRenderStrategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class NotebookRenderStrategy implements ExpandableNodeRenderStrategy {
<ExpandableNode
expanded={renderStrategy.isExpanded()} node={renderStrategy} globals={this.globals}
treeViewId={Constants.TreeView.id} key={renderStrategy.getId()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}
setsize={setsize} posinset={this.notebook.sections.length + i + 1} /> :
<LeafNode node={renderStrategy} treeViewId={Constants.TreeView.id} key={renderStrategy.getId()} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} />);
Expand All @@ -77,7 +77,7 @@ export class NotebookRenderStrategy implements ExpandableNodeRenderStrategy {
treeViewId={Constants.TreeView.id} key={renderStrategy.getId()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} /> :
<LeafNode node={renderStrategy} treeViewId={Constants.TreeView.id} key={renderStrategy.getId()} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}
setsize={setsize} posinset={i + 1} />);

return [...createNewSection, ...sections, ...sectionGroups];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class RecentSectionHeaderRenderStrategy extends RecentSectionsCommonPrope
key={renderStrategy.getId() + 'recent-section'}
id={renderStrategy.getId()}
ariaSelected={this.props.ariaSelectedId ? renderStrategy.isAriaSelected() : false}
selected={renderStrategy.isSelected()}
level={childrenLevel} setsize={this.sections.length} posinset={i + 1}></LeafNode>);

return [...sections];
Expand Down
4 changes: 2 additions & 2 deletions src/components/sectionGroupRenderStrategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class SectionGroupRenderStrategy implements ExpandableNodeRenderStrategy
<ExpandableNode
expanded={renderStrategy.isExpanded()} node={renderStrategy} globals={this.globals}
treeViewId={Constants.TreeView.id} key={renderStrategy.getId()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}
setsize={setsize} posinset={this.sectionGroup.sections.length + i + 1} /> :
<LeafNode node={renderStrategy} treeViewId={Constants.TreeView.id} key={renderStrategy.getId()} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} />);
Expand All @@ -72,7 +72,7 @@ export class SectionGroupRenderStrategy implements ExpandableNodeRenderStrategy
treeViewId={Constants.TreeView.id} key={renderStrategy.getId()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} /> :
<LeafNode node={renderStrategy} treeViewId={Constants.TreeView.id} key={renderStrategy.getId()} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}
setsize={setsize} posinset={i + 1} />);

return [...createNewSection, ...sections, ...sectionGroups];
Expand Down
2 changes: 1 addition & 1 deletion src/components/sectionRenderStrategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class SectionRenderStrategy implements ExpandableNodeRenderStrategy {
const pages = pageRenderStrategies && pageRenderStrategies.map(renderStrategy =>
<LeafNode treeViewId={Constants.TreeView.id} node={renderStrategy} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel}
ariaSelected={renderStrategy.isAriaSelected()} />);
ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}/>);

return pages || [] as JSX.Element[];
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/sharedNotebookRenderStrategy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class SharedNotebookRenderStrategy implements ExpandableNodeRenderStrateg
treeViewId={Constants.TreeView.id} key={renderStrategy.getId()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} /> :
<LeafNode node={renderStrategy} treeViewId={Constants.TreeView.id} key={renderStrategy.getId()} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}
setsize={setsize} posinset={i + 1} />);

const sectionGroupRenderStrategies = this.notebook.apiProperties.spSectionGroups.map(sectionGroup => new SectionGroupRenderStrategy(sectionGroup, this.globals));
Expand All @@ -102,7 +102,7 @@ export class SharedNotebookRenderStrategy implements ExpandableNodeRenderStrateg
<ExpandableNode
expanded={renderStrategy.isExpanded()} node={renderStrategy} globals={this.globals}
treeViewId={Constants.TreeView.id} key={renderStrategy.getId()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} selected={renderStrategy.isSelected()}
setsize={setsize} posinset={this.notebook.apiProperties!.spSections.length + i + 1} /> :
<LeafNode node={renderStrategy} treeViewId={Constants.TreeView.id} key={renderStrategy.getId()} globals={this.globals}
id={renderStrategy.getId()} level={childrenLevel} ariaSelected={renderStrategy.isAriaSelected()} />);
Expand Down
2 changes: 2 additions & 0 deletions src/components/treeView/commonNodeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface CommonNodeProps {
setsize?: number;
posinset?: number;

selected?: boolean;

// For VoiceOver accessibility, there must always be one aria-selected item.
// If there's no actual selected item, this should be the first item.
ariaSelected: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/treeView/expandableNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class ExpandableNode extends React.Component<ExpandableNodeProps, Expanda
<a id={this.descendentId()} className='picker-row' onClick={this.onClick.bind(this)} onKeyDown={this.onKeyDown.bind(this)}
data-treeviewid={this.props.treeViewId} data-id={this.props.id}
tabIndex={this.props.ariaSelected ? 0 : -1} role='treeitem' aria-labelledby={this.descendentId()}
aria-expanded={this.props.node.isExpanded()} aria-selected={this.props.ariaSelected}
aria-expanded={this.props.node.isExpanded()} aria-selected={this.props.selected}
aria-level={this.level()} aria-setsize={this.props.setsize} aria-posinset={this.props.posinset}>
{this.props.children || this.props.node.element()}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/treeView/leafNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class LeafNode extends React.Component<LeafNodeProps, {}> {
<a id={this.descendentId()} className='picker-row' onClick={this.onClick.bind(this)} onKeyDown={this.onKeyDown.bind(this)}
data-treeviewid={this.props.treeViewId} data-id={this.props.id} tabIndex={this.props.ariaSelected ? 0 : -1}
role='treeitem' aria-labelledby={this.descendentId()} aria-level={this.level()}
aria-selected={this.props.ariaSelected} aria-setsize={this.props.setsize} aria-posinset={this.props.posinset}>
aria-selected={this.props.selected} aria-setsize={this.props.setsize} aria-posinset={this.props.posinset}>
{this.props.node.element()}
</a>
</li>);
Expand Down