Skip to content
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

Do not set the dockpanel as parent of the tabbar #606

Merged
merged 7 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/widgets/src/docklayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,8 @@ export class DockLayout extends Layout {
// Enforce necessary tab bar behavior.
tabBar.orientation = 'horizontal';

// Reparent and attach the tab bar to the parent if possible.
// Attach the tab bar to the parent if possible.
if (this.parent) {
tabBar.parent = this.parent;
this.attachWidget(tabBar);
}

Expand Down
9 changes: 9 additions & 0 deletions packages/widgets/tests/src/dockpanel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ describe('@lumino/widgets', () => {
let panel = new DockPanel();
expect(panel.hasClass('lm-DockPanel')).to.equal(true);
});

it('should not have tabbar as child', () => {
let panel = new DockPanel();
let w1 = new Widget();
panel.addWidget(w1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry to drop a comment out of the blue, but I stumbled on this PR while researching something else, and I realized that while trying to read the code in this PR that these two lines in the test function are not self-evident to me. Should they be followed with an assertion?

Suggested change
let w1 = new Widget();
panel.addWidget(w1);
let w1 = new Widget();
panel.addWidget(w1);
expect(panel.contains(w1)).to.be.true;

Copy link
Contributor Author

@brichet brichet Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to this modification, the TabBar was added as a child widget of the DockPanel, as well as the document panels. The TabBar was only added if at least one widget had been added to the DockPanel.
This test adds a widget only to ensure the TabBar is not added to the child widgets list (which was the case prior to this PR).
In fact I believe it should be simplified, maybe this is what confused you.

Suggested change
let w1 = new Widget();
panel.addWidget(w1);
panel.addWidget(new Widget());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TabBar was only added if at least one widget had been added to the DockPanel.

Without knowing these implementation details, somebody reading this test has to guess at the intent of the panel.addWidget() call. Could you clarify your intent with a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f0a3d33

for (const tabBar of panel.tabBars()) {
expect(panel.contains(tabBar)).to.be.false;
}
});
});

describe('#dispose()', () => {
Expand Down