Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c2749052
Commit
c2749052
authored
Oct 08, 2019
by
Miguel Carvajal
Committed by
Torkel Ödegaard
Oct 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graph: make ContextMenu potitioning aware of the viewport width (#19699)
parent
0a2d5e16
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx
+20
-9
No files found.
packages/grafana-ui/src/components/ContextMenu/ContextMenu.tsx
View file @
c2749052
...
@@ -162,15 +162,7 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.memo(({ x, y, onClo
...
@@ -162,15 +162,7 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.memo(({ x, y, onClo
return
(
return
(
<
Portal
>
<
Portal
>
<
div
<
div
ref=
{
menuRef
}
style=
{
getStyle
(
menuRef
.
current
)
}
className=
{
styles
.
wrapper
}
>
ref=
{
menuRef
}
style=
{
{
position
:
'fixed'
,
left
:
x
-
5
,
top
:
y
+
5
,
}
}
className=
{
styles
.
wrapper
}
>
{
renderHeader
&&
<
div
className=
{
styles
.
header
}
>
{
renderHeader
()
}
</
div
>
}
{
renderHeader
&&
<
div
className=
{
styles
.
header
}
>
{
renderHeader
()
}
</
div
>
}
<
List
<
List
items=
{
items
||
[]
}
items=
{
items
||
[]
}
...
@@ -185,6 +177,25 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.memo(({ x, y, onClo
...
@@ -185,6 +177,25 @@ export const ContextMenu: React.FC<ContextMenuProps> = React.memo(({ x, y, onClo
</
div
>
</
div
>
</
Portal
>
</
Portal
>
);
);
function
getStyle
(
menuNode
:
HTMLDivElement
|
null
)
{
const
haventMeasuredMenuYet
=
!
menuNode
;
if
(
haventMeasuredMenuYet
)
{
return
{
visibility
:
'hidden'
as
const
};
}
const
rect
=
menuNode
!
.
getBoundingClientRect
();
const
OFFSET
=
5
;
const
collisions
=
{
right
:
window
.
innerWidth
<
x
+
rect
.
width
,
bottom
:
window
.
innerHeight
<
rect
.
bottom
+
rect
.
height
+
OFFSET
,
};
return
{
position
:
'fixed'
as
const
,
left
:
collisions
.
right
?
x
-
rect
.
width
-
OFFSET
:
x
-
OFFSET
,
top
:
collisions
.
bottom
?
y
-
rect
.
height
-
OFFSET
:
y
+
OFFSET
,
};
}
});
});
interface
ContextMenuItemProps
{
interface
ContextMenuItemProps
{
...
...
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