-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Introduce Dynamic Tab Resizing Strategy #12360
Conversation
197b7c3
to
bcb3ef1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! I left some comments in the code.
The new behavior brings in some weirdness: When the tabs fill the whole width and we switch to a new tab which adds/removes decorations, the tab size then only changes once the mouse leaves the tab area. That behavior is as defined but it the sudden jump in tab width feels unintuitive and weird. Maybe we can find a better solution in the long run.
I found another ugly behavior where the close button is flickering. However I checked, this is already the case on master
, so it was not introduced here:
e122b3e
to
96040ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great for me. I have one small nitpick left (from my own suggestion)
96040ae
to
477d033
Compare
@msujew @vince-fugnitto unfortunately, @sdirix is not a committer. Maybe I could get a "Hallelujah" for one of you? |
'workbench.tab.shrinkToFit.enabled': { | ||
type: 'boolean', | ||
default: false, | ||
description: nls.localize('theia/core/tabShrinkToFit', 'Shrink tabs to fit available space') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: for consistency preferences usually include punctuation
description: nls.localize('theia/core/tabShrinkToFit', 'Shrink tabs to fit available space') | |
description: nls.localize('theia/core/tabShrinkToFit', 'Shrink tabs to fit available space.') |
The same is true for other preferences introduced in the pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other preferences also use whole sentences in the description, where a period at the end makes sense.
@@ -96,13 +96,25 @@ export class DockPanelRenderer implements DockLayout.IRenderer { | |||
@inject(TabBarToolbarRegistry) protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry, | |||
@inject(TabBarToolbarFactory) protected readonly tabBarToolbarFactory: TabBarToolbarFactory, | |||
@inject(BreadcrumbsRendererFactory) protected readonly breadcrumbsRendererFactory: BreadcrumbsRendererFactory, | |||
@inject(CorePreferences) protected readonly corePreferences: CorePreferences |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document this as a breaking change:
@@ -885,7 +956,7 @@ export class SideTabBar extends ScrollableTabBar { | |||
* Render the tab bar in the _hidden content node_ (see `hiddenContentNode` for explanation), | |||
* then gather size information for labels and render it again in the proper content node. | |||
*/ | |||
protected renderTabBar(): void { | |||
protected override updateTabs(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document as a breaking change?
@@ -571,6 +602,14 @@ export class ScrollableTabBar extends TabBar<Widget> { | |||
if (!this.scrollBar) { | |||
this.scrollBar = this.scrollBarFactory(); | |||
} | |||
this.node.addEventListener('mouseenter', () => { this.isMouseOver = true; }); | |||
this.node.addEventListener('mouseleave', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives a slightly odd behavior if tabs are closed but we remain in the tabbar, perhaps we should recompute when a tab is created/closed?
shrink-to-fit-listener.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is intentional in order to keep the position of the "close" icon stable as we repeatedly close tabs. It's inspired by what Chrome does. I would argue the utility in this case outweighs the visual oddity.
.p-TabBar-tab .theia-tab-icon-label { | ||
flex: 1; | ||
} | ||
|
||
.p-TabBar-tab.p-mod-closable:hover .theia-tab-icon-label, | ||
.p-TabBar-tab.p-mod-current .theia-tab-icon-label { | ||
overflow: hidden; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that this styling causes the following regression, and possibly others:
shrink-regression.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest updates look good to me 👍
Part of eclipse-theia#12328 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
8e0142a
to
6fb11a5
Compare
What it does
Introduces a new, optional tab layout strategy similar to Chrome tabs as described in #12328
This is part one, introducing only the dynamic tab resizing.
How to test
Review checklist
Reminder for reviewers