Skip to content

Commit

Permalink
fix: prevent resetting of domains when no interaction handlers are gi…
Browse files Browse the repository at this point in the history
…ven (#508)
  • Loading branch information
TCL735 authored Mar 24, 2021
1 parent 7e23e2b commit 0ec0b5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion giraffe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@influxdata/giraffe",
"version": "2.6.1",
"version": "2.6.2",
"main": "dist/index.js",
"module": "src/index.js",
"license": "MIT",
Expand Down
7 changes: 2 additions & 5 deletions giraffe/src/components/SizedPlot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ describe('the SizedPlot', () => {
/>
)

// when the user (for real) does a single click, then a mouse up happens.
// chose mouse up because the single click listener wasn't triggering except on
// double clicks
fireEvent.mouseUp(screen.getByTestId('giraffe-inner-plot'))
fireEvent.doubleClick(screen.getByTestId('giraffe-inner-plot'))

expect(resetSpy).toHaveBeenCalled()
})
Expand All @@ -83,7 +80,7 @@ describe('the SizedPlot', () => {
/>
)
// when the user (for real) does a single click, then a mouse up happens.
// chose mouse up because the single click listener wasn't triggering except on
// choose mouse up because the single click listener wasn't triggering except on
// double clicks
fireEvent.mouseUp(screen.getByTestId('giraffe-inner-plot'))

Expand Down
4 changes: 3 additions & 1 deletion giraffe/src/components/SizedPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ export const SizedPlot: FunctionComponent<Props> = ({
},
}

const noOp = () => {}
const singleClick = config.interactionHandlers?.singleClick
? () => {
config.interactionHandlers.singleClick(plotInteraction)
}
: memoizedResetDomains
: noOp

if (config.interactionHandlers?.hover) {
config.interactionHandlers.hover(plotInteraction)
Expand Down Expand Up @@ -150,6 +151,7 @@ export const SizedPlot: FunctionComponent<Props> = ({
cursor: `${userConfig.cursor || 'crosshair'}`,
}}
onMouseUp={callbacks.singleClick}
onDoubleClick={memoizedResetDomains}
{...hoverTargetProps}
{...dragTargetProps}
>
Expand Down

0 comments on commit 0ec0b5f

Please sign in to comment.