File tree 2 files changed +21
-10
lines changed
2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -43,26 +43,28 @@ function Button(props) {
43
43
}
44
44
45
45
useEffect ( ( ) => {
46
- return ( ) => {
47
- if ( timeRef . current ) {
48
- clearTimeout ( timeRef . current ) ;
49
- }
50
- } ;
51
- } , [ ] ) ;
46
+ if ( isPortalOpen ) {
47
+ const displayTime = Math . min ( 8 , 0.1 * title . length ) * 1000 ;
48
+ const timeout = setTimeout ( ( ) => {
49
+ setIsPortalOpen ( false ) ;
50
+ } , displayTime ) ;
51
+ return ( ) => clearTimeout ( timeout ) ;
52
+ }
53
+ } , [ isPortalOpen , title . length ] ) ;
52
54
53
55
54
56
return (
55
- < div
57
+ < span
56
58
onMouseDown = { handleMouseDown }
57
59
onMouseUp = { handleMouseUp }
58
60
onMouseLeave = { handleMouseUp }
59
61
>
60
62
< PositioningPortal
61
63
isOpen = { isPortalOpen }
62
64
portalContent = {
63
- < div >
65
+ < span >
64
66
{ title }
65
- </ div >
67
+ </ span >
66
68
} >
67
69
< button
68
70
className = { combinedClassName }
@@ -78,7 +80,7 @@ function Button(props) {
78
80
</ button >
79
81
</ PositioningPortal >
80
82
81
- </ div >
83
+ </ span >
82
84
83
85
)
84
86
}
Original file line number Diff line number Diff line change @@ -63,4 +63,13 @@ HoverTest.args = {
63
63
disabled : false ,
64
64
disableOnClick : false ,
65
65
children : "Hover State Button"
66
+ } ;
67
+
68
+ export const LongPressTest = Template ( SecondaryButton ) . bind ( { } ) ;
69
+ LongPressTest . args = {
70
+ onDone : null ,
71
+ title : "Press me fdsaf fdasfds ewfavdszvwea dafd adfgew vdfgreat fsdgaew" ,
72
+ disabled : false ,
73
+ disableOnClick : false ,
74
+ children : "Hover State Button"
66
75
} ;
You can’t perform that action at this time.
0 commit comments