Fix diagram mouse event handlers

This commit is contained in:
Thomas Nordquist
2019-06-05 13:22:12 +02:00
parent f8648b92a1
commit b9dcc4a9a8

View File

@@ -40,21 +40,12 @@ const style = (theme: Theme) => {
function ChartIcon(props: { classes: any, literal: JsonPropertyLocation, showDiagram: (dotPath: string, target: EventTarget) => void, hideDiagram: () => void }) { function ChartIcon(props: { classes: any, literal: JsonPropertyLocation, showDiagram: (dotPath: string, target: EventTarget) => void, hideDiagram: () => void }) {
const mouseOver = (event: React.MouseEvent<Element>) => { const mouseOver = (event: React.MouseEvent<Element>) => {
event.stopPropagation()
event.preventDefault()
if ((event.target as Element).tagName !== 'path') {
props.showDiagram(props.literal.path, event.target) props.showDiagram(props.literal.path, event.target)
} }
}
const mouseOut = (event: React.MouseEvent) => { const mouseOut = (event: React.MouseEvent) => {
event.stopPropagation()
event.preventDefault()
if ((event.target as Element).tagName !== 'path') {
props.hideDiagram() props.hideDiagram()
} }
}
return ( return (
<ShowChart className={props.classes.icon} onMouseEnter={mouseOver} onMouseLeave={mouseOut} /> <ShowChart className={props.classes.icon} onMouseEnter={mouseOver} onMouseLeave={mouseOut} />