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

Added selected tab announcement for Linux OS #88

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions packages/app/client/src/ui/shell/mdi/tab/tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,9 @@
right: 0;
background-color: var(--tab-separator-bg);
}

.aria-live-region {
position: absolute;
top: -9999px;
overflow: hidden;
}
1 change: 1 addition & 0 deletions packages/app/client/src/ui/shell/mdi/tab/tab.scss.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const draggedOverEditorTab: string;
export const activeEditorTab: string;
export const tabFocusTarget: string;
export const tabSeparator: string;
export const ariaLiveRegion: string;
79 changes: 46 additions & 33 deletions packages/app/client/src/ui/shell/mdi/tab/tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import { TruncateText } from '@bfemulator/ui-react';
import * as React from 'react';
import { DragEvent, KeyboardEvent, SyntheticEvent } from 'react';
import { isLinux } from '@bfemulator/app-shared';

import { getTabGroupForDocument } from '../../../../state/helpers/editorHelpers';
import { DOCUMENT_ID_APP_SETTINGS, DOCUMENT_ID_MARKDOWN_PAGE, DOCUMENT_ID_WELCOME_PAGE } from '../../../../constants';
Expand Down Expand Up @@ -80,42 +81,45 @@ export class Tab extends React.Component<TabProps, TabState> {
const iconClass = this.iconClass;

return (
<div
className={`${styles.tab} ${activeClassName} ${draggedOverClassName}`}
draggable={true}
onDragOver={this.onDragOver}
onDragEnter={this.onDragEnter}
onDragStart={this.onDragStart}
onDrop={this.onDrop}
onDragLeave={this.onDragLeave}
onDragEnd={this.onDragEnd}
role="presentation"
>
{this.props.children}
{!this.props.hideIcon && <span className={`${styles.editorTabIcon} ${iconClass}`} role="presentation" />}
<TruncateText className={styles.truncatedTabText}>{label}</TruncateText>
{this.props.dirty ? <span role="presentation">*</span> : null}
<div className={styles.tabSeparator} role="presentation" />
<>
<div
className={styles.tabFocusTarget}
role="tab"
tabIndex={0}
aria-label={`${label}`}
aria-selected={active}
ref={this.setTabRef}
className={`${styles.tab} ${activeClassName} ${draggedOverClassName}`}
draggable={true}
onDragOver={this.onDragOver}
onDragEnter={this.onDragEnter}
onDragStart={this.onDragStart}
onDrop={this.onDrop}
onDragLeave={this.onDragLeave}
onDragEnd={this.onDragEnd}
role="presentation"
>
&nbsp;
{this.props.children}
{!this.props.hideIcon && <span className={`${styles.editorTabIcon} ${iconClass}`} role="presentation" />}
<TruncateText className={styles.truncatedTabText}>{label}</TruncateText>
{this.props.dirty ? <span role="presentation">*</span> : null}
<div className={styles.tabSeparator} role="presentation" />
<div
className={styles.tabFocusTarget}
role="tab"
tabIndex={0}
aria-label={`${label}`}
aria-selected={active}
ref={this.setTabRef}
>
&nbsp;
</div>
<button
type="button"
title={`Close ${label} tab`}
className={styles.editorTabClose}
onKeyPress={this.onCloseButtonKeyPress}
onClick={this.onCloseClick}
>
<span />
</button>
</div>
<button
type="button"
title={`Close ${label} tab`}
className={styles.editorTabClose}
onKeyPress={this.onCloseButtonKeyPress}
onClick={this.onCloseClick}
>
<span />
</button>
</div>
{isLinux() ? this.announceTabState : null}
</>
);
}

Expand Down Expand Up @@ -189,4 +193,13 @@ export class Tab extends React.Component<TabProps, TabState> {
private setTabRef = (ref: HTMLButtonElement): void => {
this.tabRef = ref;
};

private get announceTabState(): React.ReactNode {
const { active, label } = this.props;
return (
<span id="tabState" aria-live={'polite'} className={styles.ariaLiveRegion}>
{active ? `${label} tab selected` : ''}
</span>
);
}
}