@@ -69,28 +69,46 @@ export default class ToolbarButton<
69
69
}
70
70
}
71
71
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
+
72
91
private readonly _buttonOnclick = this . buttonOnclick . bind ( this )
73
92
74
- public render ( ) {
93
+ /** @return a react component for the button */
94
+ private content ( ) {
75
95
const { button } = this . props
76
96
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
81
97
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 >
94
108
)
95
109
}
110
+
111
+ public render ( ) {
112
+ return ! this . needsTooltip ( ) ? this . content ( ) : < Tooltip content = { this . tooltipText } > { this . content ( ) } </ Tooltip >
113
+ }
96
114
}
0 commit comments