Skip to content

Commit

Permalink
core: show tabbar when items are present (#12307)
Browse files Browse the repository at this point in the history
The commit fixes an issue with the `TabBarToolbar`, where at the React 18 uplift, an old `onRender` disposable in the `TabBarToolbar` class was replaced with a new-style `onRender` mechanism, which, however, doesn't appear to work reliably. Simpler is just revealing the toolbar immediately, knowing that a render will come soon.

The changes mean that on application start the toolbar will be correctly rendered without the needed to switch view containers first.
  • Loading branch information
colin-grant-work authored Mar 30, 2023
1 parent 99b8648 commit cd61379
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ export class TabBarToolbar extends ReactWidget {
super();
this.addClass(TabBarToolbar.Styles.TAB_BAR_TOOLBAR);
this.hide();
this.onRender = this.onRender.bind(this);
}

protected onRender = () => this.show();

updateItems(items: Array<TabBarToolbarItem | ReactTabBarToolbarItem>, current: Widget | undefined): void {
this.inline.clear();
this.more.clear();
Expand All @@ -81,7 +78,9 @@ export class TabBarToolbar extends ReactWidget {
this.updateContextKeyListener(contextKeys);

this.setCurrent(current);
if (!items.length) {
if (items.length) {
this.show();
} else {
this.hide();
}
this.update();
Expand Down Expand Up @@ -152,7 +151,6 @@ export class TabBarToolbar extends ReactWidget {
const toolbarItemClassNames = this.getToolbarItemClassNames(item);
if (item.menuPath && !item.command) { toolbarItemClassNames.push('enabled'); }
return <div key={item.id}
ref={this.onRender}
className={toolbarItemClassNames.join(' ')}
onMouseDown={this.onMouseDownEvent}
onMouseUp={this.onMouseUpEvent}
Expand Down

0 comments on commit cd61379

Please sign in to comment.