Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
40 changes: 34 additions & 6 deletions packages/widgets/src/tabbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,28 @@ export class TabBar<T> extends Widget {
return;
}

// Get focus element that is in focus by the tab key
const focusedElement = document.activeElement;
// Check if Delete key has been pressed and Delete that tab
if (event.key === 'Delete') {
const index = ArrayExt.findFirstIndex(this.contentNode.children, tab =>
tab.contains(focusedElement)
);
if (index >= 0) {
this.currentIndex = index;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this here?

let title = this._titles[index];
event.preventDefault();
event.stopPropagation();
this._tabCloseRequested.emit({ index, title });
return;
}
}
// Check if Enter or Spacebar key has been pressed and open that tab
if (
event.key === 'Enter' ||
event.key === 'Spacebar' ||
event.key === ' '
) {
// Get focus element that is in focus by the tab key
const focusedElement = document.activeElement;

// Test first if the focus is on the add button node
if (
this.addButtonEnabled &&
Expand All @@ -808,6 +821,7 @@ export class TabBar<T> extends Widget {
} else if (ARROW_KEYS.includes(event.key)) {
// Create a list of all focusable elements in the tab bar.
const focusable: Element[] = [...this.contentNode.children];

if (this.addButtonEnabled) {
focusable.push(this.addButtonNode);
}
Expand Down Expand Up @@ -1730,7 +1744,11 @@ export namespace TabBar {
let className = this.createIconClass(data);

// If title.icon is undefined, it will be ignored.
return h.div({ className }, title.icon!, title.iconLabel);
return h.div(
{ className, 'aria-hidden': 'true' },
title.icon!,
title.iconLabel
);
}

/**
Expand All @@ -1741,7 +1759,14 @@ export namespace TabBar {
* @returns A virtual element representing the tab label.
*/
renderLabel(data: IRenderData<any>): VirtualElement {
return h.div({ className: 'lm-TabBar-tabLabel' }, data.title.label);
return h.div(
{
className: 'lm-TabBar-tabLabel',
tabindex: '-1',
'aria-hidden': 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this aria-hidden: true?

},
data.title.label
);
}

/**
Expand All @@ -1752,7 +1777,9 @@ export namespace TabBar {
* @returns A virtual element representing the tab close icon.
*/
renderCloseIcon(data: IRenderData<any>): VirtualElement {
return h.div({ className: 'lm-TabBar-tabCloseIcon' });
return h.div({
className: 'lm-TabBar-tabCloseIcon'
});
}

/**
Expand Down Expand Up @@ -1829,6 +1856,7 @@ export namespace TabBar {
createTabARIA(data: IRenderData<any>): ElementARIAAttrs | ElementBaseAttrs {
return {
role: 'tab',
'aria-label': 'Launcher',
'aria-selected': data.current.toString(),
tabindex: `${data.tabIndex ?? '-1'}`
};
Expand Down
2 changes: 1 addition & 1 deletion packages/widgets/src/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class Title<T> implements IDisposable {
}

private _label = '';
private _caption = '';
private _caption = 'Launcher';
private _mnemonic = -1;
private _icon: VirtualElement.IRenderer | undefined = undefined;
private _iconClass = '';
Expand Down
2 changes: 2 additions & 0 deletions packages/widgets/style/tabbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
.lm-TabBar-tabIcon,
.lm-TabBar-tabCloseIcon {
flex: 0 0 auto;
border: none;
background: none;
}

.lm-TabBar-tabLabel {
Expand Down