-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix overflow behavior of sidebars #13483
base: master
Are you sure you want to change the base?
Conversation
@tortmayr I still don't know how to reproduce the problem (on Windows). Is this a Linux-only thing? |
I have not tested it under Windows, but the issue was originally reported by an adopters that uses Windows so IMO it should be a cross-platform issue. I have recorded videos with more detailled steps on how to reproduce the bug on master, on how the fixed version based on this PR looks like: master_demo.mp4Fixed: pr_demo.mp4 |
@tortmayr how do you get the two gear icons at the top? That's not happening for me. |
It's explained in the To fully test this you should add (at least one) top menu to the sidebar. Otherwise application specific minimum size settings might prevent you from reszing the window to a point where all tabs are hidden. I did this by adding the following code to the app.shell.leftPanelHandler.addTopMenu({
id: 'settings-menu1',
iconClass: 'codicon codicon-settings-gear',
title: nls.localizeByDefault(CommonCommands.MANAGE_CATEGORY),
menuPath: MANAGE_MENU,
order: 1,
});
app.shell.leftPanelHandler.addTopMenu({
id: 'settings-menu2',
iconClass: 'codicon codicon-settings-gear',
title: nls.localizeByDefault(CommonCommands.MANAGE_CATEGORY),
menuPath: MANAGE_MENU,
order: 1,
});
|
2b3bc77
to
c0cc040
Compare
@tortmayr generally, I much prefer written "steps to reproduce" over a video. In a video, it's hard to discern what you mean and to follow the steps. Also, I can't copy/paste text out of a video, so I might make mistakes following the video. You have even written the text, why not just paste it here? |
Most of this was already written down in the
If the inspector-stylesheet does not show up via ctrl+p you might have to force the creation by navigating to the After that the stylesheet should be present. |
@@ -1231,28 +1233,20 @@ export class SideTabBar extends ScrollableTabBar { | |||
if (iconElements.length === 1) { | |||
const icon = iconElements[0]; | |||
rd.iconSize = { width: icon.clientWidth, height: icon.clientHeight }; | |||
actualWidth += icon.clientHeight + paddingTop + paddingBottom + this.tabRowGap; |
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.
Do we not care about the tabRowGap
anymore? Wouldn't it be relevant?
const tabStyle = window.getComputedStyle(hiddenTab); | ||
const paddingTop = parseFloat(tabStyle.paddingTop!); | ||
const paddingBottom = parseFloat(tabStyle.paddingBottom!); | ||
const paddingTop = tabStyle.paddingTop ? parseFloat(tabStyle.paddingTop) : 0; |
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.
Was this broken before? In what way?
rd.visible = false; | ||
if (overflowStartIndex === -1) { | ||
overflowStartIndex = i; | ||
} | ||
} | ||
// Add the tab row gap to the actual width after the visibility check | ||
actualWidth += marginBottom + this.tabRowGap; |
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.
Why does paddingBottom
get added before the visibility check, but "marginBottom" afterwards?
I found what I believe a new problem: here's what's happening:
I'm not sure whether I still move the mouse up after the first one disappears or whether the icon disappears without moving another pixel. It's hard to tell. |
@tortmayr here's a video showing the problem: 2024-03-27.13-56-47.mp4 |
The other problem seem fixed with this PR. |
@tsmaeder Thanks for reviewing, I will look into the bug report. |
- Ensure that last visible element also gets added to `...` overflow menu if there is not enough space - Remove special behavior for only one overflowing element - This behavior would always add a second element to the `overflow` menu if only one element is currently overflowing. This did not work for the case where only two tabs where open in the first place. In addition, it unnecessarily hide a tab in some cases even if there was enough space to render it. - Also consider potential tab margins in overflow computation Fixes eclipse-theia#13482 Contributed on behalf of STMicroelectronics
- Extract logic to compute and hide hidden tabs into `hideOverflowingTabs` method - Invoke this method from `computeOverflowingTabsData`. At this point the actual tabs bar is already rendered so we can use the actual position/height information to compute overflowing tabs instead of manually composing the available height with the hidden tabs bar in `updateTabs` - Update `AdditionalViewsMenuWidget` to use a dedicated menu path for each side. This ensures that only the hidden tabs of the corresponding sidebar are displayed when clicking the '...' button
c0cc040
to
b7fd720
Compare
@tsmaeder I finally got time to work on this again. Sorry for t he long turnaround. Regarding the problem you encountered: Since this behavior is inline with what VS Code does I opted for not changing it: vscode.mp4However, I don't have a strong opinion on that. If you think its better to adjust this and e.g. always hide the last two tabs if we enter overflowing mode I'm happy to adjust this. In general, I reworked the entire hidden tabs calculation and moved it into the In addition, I encountered a bug with the After my change this works now correctly and the left menu widget only has View A and B and the right only has View C. |
@tsmaeder Ping |
What it does
...
overflow menu if there is not enough space(Normally this only happens if there is also a top menu configured for the side bar. Otherwise application specific
min height restrictions typically prevent resizing that far)
overflow
menu if only one element is currently overflowing. This did not work for the case where only two tabs where open in the first place. In addition, it unnecessarily hide a tab in some cases even if there was enough space to render it. This is inline with the behavior of VS Code.Fixes #13482
Contributed on behalf of STMicroelectronics
How to test
Precondition:
To fully test this you should have ta at least one top menu in the sidebar. Otherwise application specific minimum size settings might prevent you from reszing the window to a point where all tabs are hidden.
I did this by adding the following code to the
configure
method of theCommonFrontendContribution
The test the overflow behavior by resizing the window.
In particular you should ensure that the previously bugged corner cases are now working as expected
Overflow with only two open tabs.
On master the overflow behavior does not work as expected. Instead of showing the
...
menu the view icons just flicker.Ensure that the last not-hidden tab (i.e. the first tab overall) also gets hidden if there is not enough space
Ensure that overflow is working correctly if margins are added via custom styling
You can do this in the dev tools by adding he following rule to the
inspector stylesheet
If the
inspector-stylesheet
does not show up via ctrl+p you might have to force the creation by navigating to theelements
tabs and applying a new style via thetoolbox
in the styles section:After that the stylesheet should be present.
See also this short demo video for reference:
overflow-demo.mp4
Follow-ups
Review checklist
Reminder for reviewers