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
38daf0cb
Unverified
Commit
38daf0cb
authored
Feb 16, 2021
by
kay delaney
Committed by
GitHub
Feb 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI/Card: Fix handling of 'onClick' callback (#31225)
parent
350dcb99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
+13
-1
packages/grafana-ui/src/components/Card/Card.test.tsx
+12
-0
packages/grafana-ui/src/components/Card/Card.tsx
+1
-1
No files found.
packages/grafana-ui/src/components/Card/Card.test.tsx
0 → 100644
View file @
38daf0cb
import
React
from
'react'
;
import
{
render
,
screen
,
fireEvent
}
from
'@testing-library/react'
;
import
{
Card
}
from
'./Card'
;
describe
(
'Card'
,
()
=>
{
it
(
'should execute callback when clicked'
,
()
=>
{
const
callback
=
jest
.
fn
();
render
(<
Card
heading=
"Test Heading"
onClick=
{
callback
}
/>);
fireEvent
.
click
(
screen
.
getByText
(
'Test Heading'
));
expect
(
callback
).
toBeCalledTimes
(
1
);
});
});
packages/grafana-ui/src/components/Card/Card.tsx
View file @
38daf0cb
...
...
@@ -101,7 +101,7 @@ export const Card: CardInterface = ({
const
disableEvents
=
disabled
&&
!
actions
;
const
containerStyles
=
getContainerStyles
(
theme
,
disableEvents
,
disableHover
);
const
onCardClick
=
useCallback
(()
=>
(
disableHover
?
()
=>
{}
:
onClick
),
[
disableHover
,
onClick
]);
const
onCardClick
=
useCallback
(()
=>
(
disableHover
?
()
=>
{}
:
onClick
?.()
),
[
disableHover
,
onClick
]);
return
(
<
CardContainer
...
...
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