Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
37c3d342
Commit
37c3d342
authored
Jul 10, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make controlled tooltip for mobile
parent
4f122b9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
TriggerButton.tsx
ui/marketplace/Rating/TriggerButton.tsx
+18
-3
No files found.
ui/marketplace/Rating/TriggerButton.tsx
View file @
37c3d342
import
{
Button
,
chakra
,
useColorModeValue
,
Tooltip
}
from
'
@chakra-ui/react
'
;
import
{
Button
,
chakra
,
useColorModeValue
,
Tooltip
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
usePreventFocusAfterModalClosing
from
'
lib/hooks/usePreventFocusAfterModalClosing
'
;
import
usePreventFocusAfterModalClosing
from
'
lib/hooks/usePreventFocusAfterModalClosing
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
...
@@ -29,12 +30,25 @@ const TriggerButton = (
...
@@ -29,12 +30,25 @@ const TriggerButton = (
const
textColor
=
useColorModeValue
(
'
blackAlpha.800
'
,
'
whiteAlpha.800
'
);
const
textColor
=
useColorModeValue
(
'
blackAlpha.800
'
,
'
whiteAlpha.800
'
);
const
onFocusCapture
=
usePreventFocusAfterModalClosing
();
const
onFocusCapture
=
usePreventFocusAfterModalClosing
();
// have to implement controlled tooltip on mobile because of the issue - https://github.com/chakra-ui/chakra-ui/issues/7107
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
isMobile
=
useIsMobile
();
const
handleClick
=
React
.
useCallback
(()
=>
{
if
(
canRate
)
{
onClick
();
}
else
if
(
isMobile
)
{
onToggle
();
}
},
[
canRate
,
isMobile
,
onToggle
,
onClick
]);
return
(
return
(
<
Tooltip
<
Tooltip
label=
{
getTooltipText
(
canRate
)
}
label=
{
getTooltipText
(
canRate
)
}
openDelay=
{
100
}
openDelay=
{
100
}
textAlign=
"center"
textAlign=
"center"
closeOnClick=
{
Boolean
(
canRate
)
}
closeOnClick=
{
Boolean
(
canRate
)
||
isMobile
}
isOpen=
{
isMobile
?
isOpen
:
undefined
}
>
>
<
Button
<
Button
ref=
{
ref
}
ref=
{
ref
}
...
@@ -42,7 +56,7 @@ const TriggerButton = (
...
@@ -42,7 +56,7 @@ const TriggerButton = (
variant=
"outline"
variant=
"outline"
border=
{
0
}
border=
{
0
}
p=
{
0
}
p=
{
0
}
onClick=
{
canRate
?
onClick
:
undefined
}
onClick=
{
handleClick
}
fontSize=
{
fullView
?
'
md
'
:
'
sm
'
}
fontSize=
{
fullView
?
'
md
'
:
'
sm
'
}
fontWeight=
{
fullView
?
'
400
'
:
'
500
'
}
fontWeight=
{
fullView
?
'
400
'
:
'
500
'
}
lineHeight=
"21px"
lineHeight=
"21px"
...
@@ -50,6 +64,7 @@ const TriggerButton = (
...
@@ -50,6 +64,7 @@ const TriggerButton = (
isActive=
{
isActive
}
isActive=
{
isActive
}
onFocusCapture=
{
onFocusCapture
}
onFocusCapture=
{
onFocusCapture
}
cursor=
{
canRate
?
'
pointer
'
:
'
default
'
}
cursor=
{
canRate
?
'
pointer
'
:
'
default
'
}
onMouseLeave=
{
isMobile
?
onClose
:
undefined
}
>
>
{
!
fullView
&&
(
{
!
fullView
&&
(
<
IconSvg
<
IconSvg
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment