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(classifier): Polygon tool drag handles #6550

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Dec 12, 2024

Refactor the polygon tool drag handles so that pointerdown does not close and finish the shape, overriding the pointer dragging behaviour. Instead, the shape is closed and finished on pointerup.

Refactor the draggable decorator so that it decorates any existing onPointerDown, onPointerMove, and onPointerUp handlers with draggable behaviour. The draggable behaviour is run before the existing handler, for each event.

Please request review from @zooniverse/frontend team or an individual member of that team.

Package

  • lib-classifier

Linked Issue and/or Talk Post

How to Review

Screen.Recording.2024-12-12.at.16.06.48.mov

Clicking a drag handle should still close and finish a polygon, but pointerdown should now start dragging where previously it was cancelled.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

Bug Fix

  • The PR creator has listed user actions to use when testing if bug is fixed
  • The bug is fixed
  • Unit tests are added or updated

@coveralls
Copy link

coveralls commented Dec 12, 2024

Coverage Status

coverage: 77.355% (-0.04%) from 77.39%
when pulling 9f60321 on eatyourgreens:fix-polygon-drag-handles
into cfb661a on zooniverse:master.

@@ -72,7 +72,6 @@ function Polygon({ active, mark, scale, onFinish }) {
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
/>
)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The polygon tool code is actually broken here, and has been for a while. 😳

@goplayoutside3 goplayoutside3 self-assigned this Dec 16, 2024
@goplayoutside3 goplayoutside3 added the bug Something isn't working label Dec 16, 2024
Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I can move the drag point by running this PR with https://localhost.zooniverse.org:3000/projects/eatyourgreens/-project-testing-ground/classify/workflow/3370?env=staging, when I release the drag point then move my mouse around the subject viewer, hovering sometimes picks up the drag point again. Do you see that behavior too? I'm using Brave Browser on MacOS.

@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Dec 16, 2024

I haven’t seen that, but it sounds like a bug where pointer capture isn’t automatically released on pointer up.

@goplayoutside3 do you see that same bug on other shapes that use drag handles; lines, rectangles, or ellipses? Are you using a mouse or a trackpad? I'm using a trackpad, which might be the difference.

EDIT: I've just been able to reproduce it in the storybook in Firefox. I'll add a comment to the code diff.

@eatyourgreens eatyourgreens force-pushed the fix-polygon-drag-handles branch from f7435ad to c791810 Compare December 16, 2024 10:49
@@ -84,7 +83,7 @@ function Polygon({ active, mark, scale, onFinish }) {
y={point.y}
fill='currentColor'
dragMove={point.moveTo}
onPointerDown={handleClosePolygon}
onPointerUp={handleClosePolygon}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this overrode onPointerDown for draggable elements, which stopped dragging from happening at all. Now it overrides onPointerUp which means dragging is never canceled once it has started. 😳

Copy link
Contributor Author

@eatyourgreens eatyourgreens Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4059705, but that partly reverts #3536.

Copy link
Contributor Author

@eatyourgreens eatyourgreens Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b3b8304 might be a better fix. It decorates existing event handlers with draggable behaviour, rather than replacing or overriding them.

Copy link
Contributor Author

@eatyourgreens eatyourgreens Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in Chrome and Firefox with a few different drawing tools. Seems to work OK, and dragging is now cancelled on pointer up, while also running the mark's pointerup handler.
https://localhost:8080/?project=eatyourgreens%2F-project-testing-ground&workflow=3370

Drawing while zoomed-in still triggers #6490 in Firefox, but that's a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ellipse tool still seems to work as expected in I Fancy Cats.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR description too, as the scope has changed from the polygon tool to the draggable decorator.

@eatyourgreens eatyourgreens force-pushed the fix-polygon-drag-handles branch 2 times, most recently from b3b8304 to 09e19d6 Compare December 16, 2024 16:41
Refactor the polygon tool drag handles so that `pointerdown` does not close and finish the shape, overriding the pointer dragging behaviour. Instead, the shape is closed and finished on `pointerup`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drag handles are broken for polygon drawing tool
3 participants