Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
experience_builder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
experience_builder
Commits
c3fae5a6
Commit
c3fae5a6
authored
11 months ago
by
utkarsh_33
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the flickering problem
parent
3b3096a1
No related branches found
No related tags found
1 merge request
!96
#3459249: Handled context menu on right click
Pipeline
#273062
passed with warnings
11 months ago
Stage: development
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ui/src/features/layout/preview/RightClickMenu.tsx
+16
-14
16 additions, 14 deletions
ui/src/features/layout/preview/RightClickMenu.tsx
with
16 additions
and
14 deletions
ui/src/features/layout/preview/RightClickMenu.tsx
+
16
−
14
View file @
c3fae5a6
...
...
@@ -29,6 +29,7 @@ const RightClickMenu: React.FC<RightClickMenuProps> = (props) => {
x
:
number
;
y
:
number
;
}
>
({
x
:
0
,
y
:
0
});
const
[
isPositionUpdated
,
setIsPositionUpdated
]
=
useState
(
false
);
const
contextMenuOpenRef
=
useRef
(
contextMenuOpen
);
const
dispatch
=
useAppDispatch
();
...
...
@@ -36,30 +37,31 @@ const RightClickMenu: React.FC<RightClickMenuProps> = (props) => {
contextMenuOpenRef
.
current
=
contextMenuOpen
;
},
[
contextMenuOpen
]);
useEffect
(()
=>
{
if
(
!
iframeRef
.
current
)
{
return
;
}
const
updateContextMenuPosition
=
useCallback
(()
=>
{
if
(
iframeRef
.
current
)
{
const
iframeRect
=
iframeRef
.
current
.
getBoundingClientRect
();
if
(
mouseEventPosition
!==
null
)
{
setContextMenuPosition
({
x
:
iframeRect
.
x
+
mouseEventPosition
?.
pageX
,
y
:
iframeRect
.
y
+
mouseEventPosition
?.
pageY
,
});
}
else
{
setContextMenuPosition
({
x
:
iframeRect
.
x
,
y
:
iframeRect
.
y
,
x
:
iframeRect
.
x
+
mouseEventPosition
.
pageX
,
y
:
iframeRect
.
y
+
mouseEventPosition
.
pageY
,
});
setIsPositionUpdated
(
true
);
}
},
[
iframeRef
,
mouseEventPosition
]);
useEffect
(()
=>
{
if
(
contextMenuOpen
===
viewportSize
)
{
setIsPositionUpdated
(
false
);
updateContextMenuPosition
();
}
},
[
contextMenuOpen
,
updateContextMenuPosition
,
viewportSize
]);
const
handleLeftClick
=
useCallback
(
(
event
:
MouseEvent
)
=>
{
if
(
contextMenuOpenRef
.
current
)
{
event
.
preventDefault
();
dispatch
(
setIsContextMenuOpen
(
undefined
));
dispatch
(
unsetHoveredComponent
());
setIsPositionUpdated
(
false
);
}
},
[
dispatch
],
...
...
@@ -112,7 +114,7 @@ const RightClickMenu: React.FC<RightClickMenuProps> = (props) => {
dispatch
(
shiftNode
({
uuid
:
elementId
,
direction
:
'
down
'
}));
}
if
(
contextMenuOpen
===
viewportSize
)
{
if
(
contextMenuOpen
===
viewportSize
&&
isPositionUpdated
)
{
return
(
<>
<
DropdownMenu
.
Root
open
=
{
!!
contextMenuOpen
}
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment