Skip to content

Commit

Permalink
Merge pull request #373 from iclanton/fix-playground-accessability-is…
Browse files Browse the repository at this point in the history
…sues

Fix an issue where the selected tab isn't selectable via keyboard navigation.
  • Loading branch information
iclanton authored Mar 27, 2024
2 parents fcffaae + 87c62f7 commit 7d9fa37
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.github/CODEOWNERS @iclanton @nickpape-msft @octogonz
common/config/**/* @iclanton @nickpape-msft @octogonz
.github/CODEOWNERS @iclanton @octogonz @apostolisms @D4N14L @dmichon-msft @patmill
common/config/**/* @iclanton @octogonz @apostolisms @D4N14L @dmichon-msft @patmill

**/* @iclanton @nickpape-msft @octogonz
**/* @iclanton @octogonz @apostolisms @D4N14L @dmichon-msft @patmill
3 changes: 0 additions & 3 deletions common/config/azure-pipelines/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ jobs:
- job: PRBuild
condition: succeeded()
strategy:
maxParallel: 3
matrix:
'NodeJs 14':
NodeVersion: 14
'NodeJs 16':
NodeVersion: 16
'NodeJs 18':
Expand Down
2 changes: 1 addition & 1 deletion common/config/azure-pipelines/npm-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pool:
vmImage: 'ubuntu-latest'
variables:
NodeVersion: 16
NodeVersion: 18
FORCE_COLOR: 1
steps:
- checkout: self
Expand Down
2 changes: 1 addition & 1 deletion common/config/azure-pipelines/npm-republish.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pool:
vmImage: 'ubuntu-latest'
variables:
NodeVersion: 16
NodeVersion: 18
FORCE_COLOR: 1
steps:
- checkout: self
Expand Down
2 changes: 1 addition & 1 deletion common/config/azure-pipelines/playground-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
ref: refs/heads/gh-pages
trigger: none
variables:
NodeVersion: 16
NodeVersion: 18
FORCE_COLOR: 1
jobs:
- job: build
Expand Down
4 changes: 4 additions & 0 deletions common/config/azure-pipelines/templates/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ steps:
displayName: 'Rush Install'
- script: 'node common/scripts/install-run-rush.js rebuild --verbose --production'
displayName: 'Rush Rebuild'
env:
# Prevent time-based browserslist update warning
# See https://github.com/microsoft/rushstack/issues/2981
BROWSERSLIST_IGNORE_OLD_DATA: 1
61 changes: 30 additions & 31 deletions playground/src/TabPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export interface ITabPaneState {
selectedTabIndex: number;
}

const TAB_STYLE: React.CSSProperties = {
padding: '8px',
marginLeft: '1px',
marginRight: '1px'
};

export class TabPane extends React.Component<ITabPaneProps, ITabPaneState> {
// Saved bindings of _onClickTab() with a tabIndex parameter, to avoid the react/jsx-no-bind issue
private _onClickTabBindings: React.MouseEventHandler<HTMLAnchorElement>[] = [];
Expand All @@ -38,49 +44,42 @@ export class TabPane extends React.Component<ITabPaneProps, ITabPaneState> {
for (let i: number = 0; i < this.props.tabs.length; ++i) {
const tabDefinition: ITabDefinition = this.props.tabs[i];

const style: React.CSSProperties = {
padding: '8px',
marginLeft: '1px',
marginRight: '1px'
};

let ariaSelected: boolean = false;
let tabStyleToUse: React.CSSProperties;
if (i === this.state.selectedTabIndex) {
selectedTabDefinition = tabDefinition;
ariaSelected = true;

const activeTabStyle: React.CSSProperties = {
...style,
tabStyleToUse = {
...TAB_STYLE,
borderStyle: 'solid',
borderWidth: '2px',
borderColor: '#c0c0c0',
borderBottomStyle: 'none',
borderTopLeftRadius: '4px',
borderTopRightRadius: '4px'
};

buttons.push(
<div key={`tab_${i}`} className="playground-tab-pane-active-tab" style={activeTabStyle} role="tab">
{tabDefinition.title}
</div>
);
} else {
if (!this._onClickTabBindings[i]) {
// Bind _onClickTab() with i as the tabIndex parameter
this._onClickTabBindings[i] = this._onClickTab.bind(this, i);
}

buttons.push(
<div key={`tab_${i}`} className="playground-tab-pane-inactive-tab" style={style}>
<a
href="#"
style={{ textDecorationLine: 'none', color: '#000000' }}
onClick={this._onClickTabBindings[i]}
role="tab"
>
{tabDefinition.title}
</a>
</div>
);
tabStyleToUse = TAB_STYLE;
}

if (!this._onClickTabBindings[i]) {
// Bind _onClickTab() with i as the tabIndex parameter
this._onClickTabBindings[i] = this._onClickTab.bind(this, i);
}
buttons.push(
<div key={`tab_${i}`} className="playground-tab-pane-inactive-tab" style={tabStyleToUse}>
<a
href="#"
style={{ textDecorationLine: 'none', color: '#000000' }}
onClick={this._onClickTabBindings[i]}
role="tab"
aria-selected={ariaSelected}
>
{tabDefinition.title}
</a>
</div>
);
}

const contentDivStyle: React.CSSProperties = {
Expand Down

0 comments on commit 7d9fa37

Please sign in to comment.