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
262a42b2
Unverified
Commit
262a42b2
authored
Aug 27, 2020
by
kay delaney
Committed by
GitHub
Aug 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI/ClickOutsideWrapper: Adds parent prop for situations where event should be on document (#27221)
parent
093477c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx
+7
-4
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
+1
-1
No files found.
packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx
View file @
262a42b2
...
...
@@ -10,6 +10,7 @@ export interface Props {
* Runs the 'onClick' function when pressing a key outside of the current element. Defaults to true.
*/
includeButtonPress
:
boolean
;
parent
:
Window
|
Document
;
}
interface
State
{
...
...
@@ -19,22 +20,24 @@ interface State {
export
class
ClickOutsideWrapper
extends
PureComponent
<
Props
,
State
>
{
static
defaultProps
=
{
includeButtonPress
:
true
,
parent
:
window
,
};
state
=
{
hasEventListener
:
false
,
};
componentDidMount
()
{
document
.
addEventListener
(
'mousedown
'
,
this
.
onOutsideClick
,
false
);
this
.
props
.
parent
.
addEventListener
(
'click
'
,
this
.
onOutsideClick
,
false
);
if
(
this
.
props
.
includeButtonPress
)
{
document
.
addEventListener
(
'keydown'
,
this
.
onOutsideClick
,
false
);
// Use keyup since keydown already has an eventlistener on window
this
.
props
.
parent
.
addEventListener
(
'keyup'
,
this
.
onOutsideClick
,
false
);
}
}
componentWillUnmount
()
{
document
.
removeEventListener
(
'mousedown
'
,
this
.
onOutsideClick
,
false
);
this
.
props
.
parent
.
removeEventListener
(
'click
'
,
this
.
onOutsideClick
,
false
);
if
(
this
.
props
.
includeButtonPress
)
{
document
.
removeEventListener
(
'keydown
'
,
this
.
onOutsideClick
,
false
);
this
.
props
.
parent
.
removeEventListener
(
'keyup
'
,
this
.
onOutsideClick
,
false
);
}
}
...
...
public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.tsx
View file @
262a42b2
...
...
@@ -180,7 +180,7 @@ export class PanelHeader extends Component<Props, State> {
<
span
className=
"panel-title-text"
>
{
title
}
</
span
>
<
Icon
name=
"angle-down"
className=
"panel-menu-toggle"
/>
{
this
.
state
.
panelMenuOpen
&&
(
<
ClickOutsideWrapper
onClick=
{
this
.
closeMenu
}
>
<
ClickOutsideWrapper
onClick=
{
this
.
closeMenu
}
parent=
{
document
}
>
<
PanelHeaderMenu
items=
{
menuItems
}
/>
</
ClickOutsideWrapper
>
)
}
...
...
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