@@ -36,6 +36,7 @@ interface Props {
36
36
37
37
export const TabLabel : React . FC < Props > = ( { label, active, disabled, onClick, onClose, canClose, icon } ) => {
38
38
const theme = useTheme ( )
39
+ const isTouchDevice = navigator . maxTouchPoints > 0
39
40
40
41
const containerStyles : IStackStyles = useMemo ( ( ) => {
41
42
const { palette, semanticColors } = theme
@@ -84,7 +85,7 @@ export const TabLabel: React.FC<Props> = ({ label, active, disabled, onClick, on
84
85
lineHeight : 'auto' ,
85
86
fontSize : FontSizes . smallPlus ,
86
87
color : 'inherit' ,
87
- opacity : active ? '1' : '0' ,
88
+ opacity : isTouchDevice || active ? '1' : '0' ,
88
89
':focus' : {
89
90
opacity : '1' ,
90
91
} ,
@@ -97,12 +98,12 @@ export const TabLabel: React.FC<Props> = ({ label, active, disabled, onClick, on
97
98
color : 'inherit' ,
98
99
} ,
99
100
}
100
- } , [ active ] )
101
+ } , [ active , isTouchDevice ] )
101
102
102
103
const iconStyle = active ? icon ?. active : icon ?. inactive
103
104
104
105
// onAuxClick doesn't work in Chrome, so only way to capture it is onMouseUp/Down.
105
- const handleClick : React . MouseEventHandler = ( e ) => {
106
+ const handleClick : React . MouseEventHandler < HTMLElement > = ( e ) => {
106
107
switch ( e . button ) {
107
108
case BUTTON_PRIMARY :
108
109
onClick ?.( )
@@ -113,7 +114,7 @@ export const TabLabel: React.FC<Props> = ({ label, active, disabled, onClick, on
113
114
}
114
115
}
115
116
116
- const handleClose = useCallback (
117
+ const handleClose : React . MouseEventHandler < HTMLElement > = useCallback (
117
118
( e ) => {
118
119
e . stopPropagation ( )
119
120
onClose ?.( )
@@ -156,7 +157,7 @@ export const TabLabel: React.FC<Props> = ({ label, active, disabled, onClick, on
156
157
disabled = { disabled }
157
158
iconProps = { { iconName : 'Cancel' } }
158
159
styles = { btnStyles }
159
- onClick = { handleClose }
160
+ onMouseUp = { handleClose }
160
161
/>
161
162
</ Stack . Item >
162
163
) : null }
0 commit comments