|
@@ -21,23 +21,40 @@ export default class ToolboxItem extends AbstractToolboxItem<Props> {
|
21
|
21
|
*/
|
22
|
22
|
_renderItem() {
|
23
|
23
|
const {
|
|
24
|
+ disabled,
|
24
|
25
|
onClick,
|
25
|
|
- showLabel
|
|
26
|
+ showLabel,
|
|
27
|
+ tooltipPosition
|
26
|
28
|
} = this.props;
|
|
29
|
+ const className = showLabel ? 'overflow-menu-item' : 'toolbox-button';
|
27
|
30
|
const props = {
|
28
|
31
|
'aria-label': this.accessibilityLabel,
|
29
|
|
- className: showLabel ? 'overflow-menu-item' : 'toolbox-button',
|
30
|
|
- onClick
|
|
32
|
+ className: className + (disabled ? ' disabled' : ''),
|
|
33
|
+ onClick: disabled ? undefined : onClick
|
31
|
34
|
};
|
32
|
35
|
const elementType = showLabel ? 'li' : 'div';
|
|
36
|
+ const useTooltip = this.tooltip && this.tooltip.length > 0;
|
33
|
37
|
// eslint-disable-next-line no-extra-parens
|
34
|
|
- const children = (
|
|
38
|
+ let children = (
|
35
|
39
|
<Fragment>
|
36
|
40
|
{ this._renderIcon() }
|
37
|
|
- { showLabel && this.label }
|
|
41
|
+ { showLabel && <span>
|
|
42
|
+ { this.label }
|
|
43
|
+ </span> }
|
38
|
44
|
</Fragment>
|
39
|
45
|
);
|
40
|
46
|
|
|
47
|
+ if (useTooltip) {
|
|
48
|
+ // eslint-disable-next-line no-extra-parens
|
|
49
|
+ children = (
|
|
50
|
+ <Tooltip
|
|
51
|
+ content = { this.tooltip }
|
|
52
|
+ position = { tooltipPosition }>
|
|
53
|
+ { children }
|
|
54
|
+ </Tooltip>
|
|
55
|
+ );
|
|
56
|
+ }
|
|
57
|
+
|
41
|
58
|
return React.createElement(elementType, props, children);
|
42
|
59
|
}
|
43
|
60
|
|
|
@@ -48,25 +65,13 @@ export default class ToolboxItem extends AbstractToolboxItem<Props> {
|
48
|
65
|
* @returns {ReactElement}
|
49
|
66
|
*/
|
50
|
67
|
_renderIcon() {
|
51
|
|
- const { iconName, tooltipPosition, showLabel } = this.props;
|
|
68
|
+ const { iconName, showLabel } = this.props;
|
52
|
69
|
const icon = <i className = { iconName } />;
|
53
|
70
|
const elementType = showLabel ? 'span' : 'div';
|
54
|
71
|
const className
|
55
|
72
|
= showLabel ? 'overflow-menu-item-icon' : 'toolbox-icon';
|
56
|
73
|
const iconWrapper
|
57
|
74
|
= React.createElement(elementType, { className }, icon);
|
58
|
|
- const tooltip = this.tooltip;
|
59
|
|
- const useTooltip = !showLabel && tooltip && tooltip.length > 0;
|
60
|
|
-
|
61
|
|
- if (useTooltip) {
|
62
|
|
- return (
|
63
|
|
- <Tooltip
|
64
|
|
- content = { tooltip }
|
65
|
|
- position = { tooltipPosition }>
|
66
|
|
- { iconWrapper }
|
67
|
|
- </Tooltip>
|
68
|
|
- );
|
69
|
|
- }
|
70
|
75
|
|
71
|
76
|
return iconWrapper;
|
72
|
77
|
}
|