From a6fdb77472d0999a95c9e6818e229dab409db51c Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Fri, 26 Jul 2019 12:11:46 -0700 Subject: [PATCH] Only create tab keys if we have a tab bar renderer. --- packages/widgets/src/docklayout.ts | 11 +++++++---- packages/widgets/src/tabbar.ts | 13 ------------- packages/widgets/src/tabpanel.ts | 8 ++++++-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/packages/widgets/src/docklayout.ts b/packages/widgets/src/docklayout.ts index 78deb386f..fca1d254c 100644 --- a/packages/widgets/src/docklayout.ts +++ b/packages/widgets/src/docklayout.ts @@ -1994,14 +1994,17 @@ namespace Private { } export - async function addAria(widget: Widget, tabBar: TabBar) { - let tabId = tabBar.renderer.createTabKey({title: widget.title, current: false, zIndex: 0}); + function addAria(widget: Widget, tabBar: TabBar) { widget.node.setAttribute('role', 'tabpanel'); - widget.node.setAttribute('aria-labelledby', tabId); + let renderer = tabBar.renderer; + if (renderer instanceof TabBar.Renderer) { + let tabId = renderer.createTabKey({ title: widget.title, current: false, zIndex: 0 }); + widget.node.setAttribute('aria-labelledby', tabId); + } } export - async function removeAria(widget: Widget) { + function removeAria(widget: Widget) { widget.node.removeAttribute('role'); widget.node.removeAttribute('aria-labelledby'); } diff --git a/packages/widgets/src/tabbar.ts b/packages/widgets/src/tabbar.ts index 4255459a1..7cbe87c95 100644 --- a/packages/widgets/src/tabbar.ts +++ b/packages/widgets/src/tabbar.ts @@ -1434,19 +1434,6 @@ namespace TabBar { * @returns A virtual element representing the tab. */ renderTab(data: IRenderData): VirtualElement; - - /** - * Create a stable unique id for a tab based on the title. - * - * @param data - The data to use for the tab. - * - * @returns The unique id for a tab. - * - * #### Notes - * This method returns a stable unique id for a tab, depending only on the - * title. The tab DOM `id` is set to this value. - */ - createTabKey(data: IRenderData): string; } /** diff --git a/packages/widgets/src/tabpanel.ts b/packages/widgets/src/tabpanel.ts index 375de3699..7b324ca1e 100644 --- a/packages/widgets/src/tabpanel.ts +++ b/packages/widgets/src/tabpanel.ts @@ -273,9 +273,13 @@ class TabPanel extends Widget { this.stackedPanel.insertWidget(index, widget); this.tabBar.insertTab(index, widget.title); - let tabId = this.tabBar.renderer.createTabKey({title: widget.title, current: false, zIndex: 0}); widget.node.setAttribute('role', 'tabpanel'); - widget.node.setAttribute('aria-labelledby', tabId); + + let renderer = this.tabBar.renderer + if (renderer instanceof TabBar.Renderer) { + let tabId = renderer.createTabKey({title: widget.title, current: false, zIndex: 0}); + widget.node.setAttribute('aria-labelledby', tabId); + } } /**