Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: using onClick instead of mouseUp in SizedPlot.tsx #515

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions giraffe/src/components/SizedPlot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ describe('the SizedPlot', () => {
layerCanvasRef={layersRef}
/>
)
// when the user (for real) does a single click, then a mouse up happens.
// choose mouse up because the single click listener wasn't triggering except on
// double clicks
fireEvent.mouseUp(screen.getByTestId('giraffe-inner-plot'))
fireEvent.click(screen.getByTestId('giraffe-inner-plot'))

expect(resetSpy).not.toHaveBeenCalled()
expect(fakeSingleClickInteractionHandler).toHaveBeenCalled()
Expand Down
8 changes: 1 addition & 7 deletions giraffe/src/components/SizedPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ export const SizedPlot: FunctionComponent<Props> = ({
bottom: 0,
}

// for single clicking; using mouseup, since the onClick only gets through
// with a double click; and the hover and drag target does not use a mouse up;
// they are: hover: mouseEnter, mousemove, mouseleave
// drag target: mouseDown
// and every time there is a single click, the mouse goes up. so using that instead.

return (
<div
className="giraffe-plot"
Expand All @@ -150,7 +144,7 @@ export const SizedPlot: FunctionComponent<Props> = ({
left: `${margins.left}px`,
cursor: `${userConfig.cursor || 'crosshair'}`,
}}
onMouseUp={callbacks.singleClick}
onClick={callbacks.singleClick}
onDoubleClick={memoizedResetDomains}
{...hoverTargetProps}
{...dragTargetProps}
Expand Down