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

Commit 7eb4cec

Browse files
committed
fix: skip sidecar button tooltip if tooltipText==buttonLabel
1 parent e10829a commit 7eb4cec

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

plugins/plugin-client-common/src/components/Views/Sidecar/ToolbarButton.tsx

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,46 @@ export default class ToolbarButton<
6969
}
7070
}
7171

72+
/** @return text of tooltip */
73+
private get tooltipText() {
74+
const { button } = this.props
75+
76+
return button.label || button.mode
77+
}
78+
79+
/** @return label of the button */
80+
private get buttonLabel() {
81+
const { button } = this.props
82+
83+
return button.icon ? button.icon : button.label || button.mode
84+
}
85+
86+
/** @return whether we need a tooltip wrapper */
87+
private needsTooltip() {
88+
return this.tooltipText !== this.buttonLabel
89+
}
90+
7291
private readonly _buttonOnclick = this.buttonOnclick.bind(this)
7392

74-
public render() {
93+
/** @return a react component for the button */
94+
private content() {
7595
const { button } = this.props
7696

77-
// we want bottom-end, but PatternFly 4.152.4 (also 4.157.3) does
78-
// not seem to render bottom-end correctly; the caret/pointer is
79-
// not visible see
80-
// https://github.com/patternfly/patternfly/issues/4382
8197
return (
82-
<Tooltip content={button.label || button.mode}>
83-
<span
84-
className={
85-
'kui--tab-navigatable kui--notab-when-sidecar-hidden sidecar-bottom-stripe-button-as-button sidecar-bottom-stripe-button' +
86-
(button.icon ? ' kui--toolbar-button-with-icon' : '')
87-
}
88-
>
89-
<div role="presentation" onClick={this._buttonOnclick} data-mode={button.mode}>
90-
<span role="tab">{button.icon ? button.icon : button.label || button.mode}</span>
91-
</div>
92-
</span>
93-
</Tooltip>
98+
<span
99+
className={
100+
'kui--tab-navigatable kui--notab-when-sidecar-hidden sidecar-bottom-stripe-button-as-button sidecar-bottom-stripe-button' +
101+
(button.icon ? ' kui--toolbar-button-with-icon' : '')
102+
}
103+
>
104+
<div role="presentation" onClick={this._buttonOnclick} data-mode={button.mode}>
105+
<span role="tab">{this.buttonLabel}</span>
106+
</div>
107+
</span>
94108
)
95109
}
110+
111+
public render() {
112+
return !this.needsTooltip() ? this.content() : <Tooltip content={this.tooltipText}>{this.content()}</Tooltip>
113+
}
96114
}

0 commit comments

Comments
 (0)