Skip to content

Commit 905553e

Browse files
authored
Resolving some accessibility issues (#6719)
* Uses different ID for the running-session widgets, the one in main view and the one in panel * Append kernel logo image only if necessary * Add title to the button which close sidebar * Add landmarks roles * Fix UI-test * lint
1 parent 61b2ad2 commit 905553e

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

packages/application/src/panelhandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export class SidePanelHandler extends PanelHandler {
9090
this.hide();
9191
};
9292
closeButton.className = 'jp-Button jp-SidePanel-collapse';
93+
closeButton.title = 'Collapse side panel';
94+
9395
const icon = new Widget({ node: closeButton });
9496
this._panel.addWidget(icon);
9597
this._panel.addWidget(this._widgetPanel);

packages/application/src/shell.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
4545
const menuWrapper = (this._menuWrapper = new Panel());
4646

4747
this._topHandler.panel.id = 'top-panel';
48+
this._topHandler.panel.node.setAttribute('role', 'banner');
4849
this._menuHandler.panel.id = 'menu-panel';
50+
this._menuHandler.panel.node.setAttribute('role', 'navigation');
4951
this._main.id = 'main-panel';
52+
this._main.node.setAttribute('role', 'main');
5053

5154
this._spacer = new Widget();
5255
this._spacer.id = 'spacer-widget';
@@ -63,7 +66,9 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
6366
const rightHandler = this._rightHandler;
6467

6568
leftHandler.panel.id = 'jp-left-stack';
69+
leftHandler.panel.node.setAttribute('role', 'complementary');
6670
rightHandler.panel.id = 'jp-right-stack';
71+
rightHandler.panel.node.setAttribute('role', 'complementary');
6772

6873
// Hide the side panels by default.
6974
leftHandler.hide();

packages/notebook-extension/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,31 @@ const kernelLogo: JupyterFrontEndPlugin<void> = {
141141

142142
const node = document.createElement('div');
143143
const img = document.createElement('img');
144-
node.appendChild(img);
145144

146145
const onChange = async () => {
147146
const current = shell.currentWidget;
148147
if (!(current instanceof NotebookPanel)) {
149148
return;
150149
}
151150

151+
if (!node.hasChildNodes()) {
152+
node.appendChild(img);
153+
}
154+
152155
await current.sessionContext.ready;
153156
current.sessionContext.kernelChanged.disconnect(onChange);
154157
current.sessionContext.kernelChanged.connect(onChange);
155158

156159
const name = current.sessionContext.session?.kernel?.name ?? '';
157160
const spec = serviceManager.kernelspecs?.specs?.kernelspecs[name];
158161
if (!spec) {
162+
node.childNodes[0].remove();
159163
return;
160164
}
161165

162166
const kernelIconUrl = spec.resources['logo-64x64'];
163167
if (!kernelIconUrl) {
168+
node.childNodes[0].remove();
164169
return;
165170
}
166171

packages/tree-extension/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
185185

186186
if (manager) {
187187
const running = new RunningSessions(manager, translator);
188-
running.id = 'jp-running-sessions';
188+
running.id = 'jp-running-sessions-tree';
189189
running.title.label = trans.__('Running');
190190
running.title.icon = runningIcon;
191191
nbTreeWidget.addWidget(running);

ui-tests/test/tree.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ test('should update url when navigating in filebrowser', async ({
4040
test('Should activate file browser tab', async ({ page, tmpPath }) => {
4141
await page.goto(`tree/${tmpPath}`);
4242
await page.click('text="Running"');
43-
await expect(page.locator('#main-panel #jp-running-sessions')).toBeVisible();
43+
await expect(
44+
page.locator('#main-panel #jp-running-sessions-tree')
45+
).toBeVisible();
4446

4547
await page.menu.clickMenuItem('View>File Browser');
4648
await expect(page.locator('#main-panel #filebrowser')).toBeVisible();

0 commit comments

Comments
 (0)