Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 14c27ba

Browse files
myan9starpit
authored andcommitted
fix: sidecar Toolbar component renders empty if there is no Toolbar content
Fixes #4229
1 parent 04e29d2 commit 14c27ba

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

packages/test/src/api/mmr.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,22 @@ export class TestMMR {
514514
.catch(Common.oops(this, true)))
515515
})
516516
}
517+
518+
public toolbarNotExist() {
519+
const { command, testName } = this.param
520+
describe(`mmr toolbar ${testName || command || ''} ${process.env.MOCHA_RUN_TARGET ||
521+
''}`, function(this: Common.ISuite) {
522+
before(Common.before(this))
523+
after(Common.after(this))
524+
525+
it(`should not show toolbar in sidecar `, () =>
526+
CLI.command(command, this.app)
527+
.then(ReplExpect.ok)
528+
.then(SidecarExpect.open)
529+
.then(() => this.app.client.waitForExist(Selectors.SIDECAR_TOOLBAR, CLI.waitTimeout, false))
530+
.catch(Common.oops(this, true)))
531+
})
532+
}
517533
}
518534

519535
interface Label {

plugins/plugin-client-common/src/components/Sidecar/ToolbarContainer.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,20 @@ export default class ToolbarContainer extends React.PureComponent<Props, State>
4949
}
5050

5151
public render() {
52+
const toolbarButtons = this.props.buttons.concat(this.state.extraButtons || [])
53+
const toolbarHasContent = this.state.toolbarText || toolbarButtons.length !== 0
54+
5255
return (
5356
<div className="full-height">
54-
<Toolbar
55-
tab={this.props.tab}
56-
response={this.props.response}
57-
args={this.props.args}
58-
toolbarText={this.state.toolbarText}
59-
buttons={this.props.buttons.concat(this.state.extraButtons || [])}
60-
/>
57+
{toolbarHasContent && (
58+
<Toolbar
59+
tab={this.props.tab}
60+
response={this.props.response}
61+
args={this.props.args}
62+
toolbarText={this.state.toolbarText}
63+
buttons={toolbarButtons}
64+
/>
65+
)}
6166
<React.Suspense fallback={<div />}>{this.children()}</React.Suspense>
6267
</div>
6368
)

plugins/plugin-client-test/test/response/mmr-name.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ testMetadataName.name({
4545
}
4646
})
4747

48+
testMetadataName.toolbarNotExist()
49+
4850
testPrettyName.name({
4951
nameHash: 'this is the namehash part',
5052
prettyName: 'this is the prettyName part',

0 commit comments

Comments
 (0)