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: auto-scroll bugs #901

Merged
merged 3 commits into from
Sep 28, 2023
Merged

fix: auto-scroll bugs #901

merged 3 commits into from
Sep 28, 2023

Conversation

kswenson
Copy link
Member

  • improve document does auto-scroll when trying to drag attribute to graph x-axis
  • fix case table doesn't auto-scroll when dragging attributes to create hierarchical table

The problem of the document auto-scrolling when trying to drag to the x-axis of the graph is improved (although not fixed entirely) by using existing dnd-kit configuration to reduce the size of the auto-scroll area. If we want to fine-tune the auto-scroll behavior based on the element being dragged over, for instance, we'll need to make more substantial modification to dnd-kit itself.

The case table bug is fixed by patching @dnd-kit/core. The dnd-kit auto-scroll code maintains a mapping between scrollable elements and their bounding rects. In the useRects() hook, this test was used to determine when to recompute the rectangles associated with the scrollable elements:

  if (elements.length > 0 && rects === defaultValue$2) {
    measureRects();
  }

where defaultValue$2 is the default empty array. This doesn't catch the situation in which the length of the elements array changes, which is the situation we were encountering. Changing the test to this fixes the bug:

  if (elements.length !== rects.length) { // [CC]
    measureRects();
  }

For now, we're just using patch-package to deploy the fix, but I plan to submit a PR to the dnd-kit repo to contribute the fix back.

@kswenson kswenson requested a review from bfinzer September 25, 2023 23:44
@kswenson kswenson force-pushed the 186117412-autoscroll-bugs-v3 branch from 4911bb7 to 27b8435 Compare September 26, 2023 05:53
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (e342468) 80.55% compared to head (62c6788) 80.56%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #901   +/-   ##
=======================================
  Coverage   80.55%   80.56%           
=======================================
  Files         296      296           
  Lines       12253    12254    +1     
  Branches     3332     3332           
=======================================
+ Hits         9871     9872    +1     
  Misses       2249     2249           
  Partials      133      133           
Flag Coverage Δ
cypress 65.39% <100.00%> (+<0.01%) ⬆️
jest 61.11% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...rc/components/case-table/column-header-divider.tsx 68.08% <100.00%> (ø)
v3/src/components/codap-dnd-context.tsx 52.17% <100.00%> (+2.17%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kswenson kswenson requested a review from emcelroy September 27, 2023 22:11
Copy link
Contributor

@emcelroy emcelroy left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 CODAP v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants