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(explore): reordering columns with dnd sometimes glitching #16322

Merged
merged 2 commits into from
Aug 18, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Aug 18, 2021

SUMMARY

When user added 3 or more columns to a control that accepts only columns (such as Group by) and started reordering using drag and drop, the feature was starting to glitch after the first sorting.
The first dragging and dropping a column to reorder worked correctly. Due to memoization, when user wanted to reorder the second time, the drop index from the first reordering was being used as a start index of the next reordering. That caused a glitch, which resulted in columns "jumping" and changing their positions incorrectly.

Another issue related to reordering with dnd happened in filters and metrics controls. After reordering, when user clicked a metric label, the popover's content was stale - it showed the column name and aggregate of a metric that was at current index before reordering. The source of the problem seems to be antd popover's internal memoization, which we can switch off by setting a prop destroyTooltipOnHide. Before, that prop was set only for popover used to create a new metric or filter, so that user doesn't see old selections after creating a metric/filter and clicking again. Now we set that prop also for popovers used for editing metrics and filters.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: see linked issue
After:
https://user-images.githubusercontent.com/15073128/129889010-9e5c5a1e-28f7-41e2-a3b0-46bf6d446b86.mov

TESTING INSTRUCTIONS

  1. Enable dnd feature flag
  2. Open a chart and add 3 or more columns
  3. Reorder the columns by drag and dropping and verify that it works correctly

ADDITIONAL INFORMATION

CC @junlincc @jinghua-qa

@codecov
Copy link

codecov bot commented Aug 18, 2021

Codecov Report

Merging #16322 (191fa12) into master (4960b5e) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16322      +/-   ##
==========================================
- Coverage   76.65%   76.65%   -0.01%     
==========================================
  Files         999      999              
  Lines       53397    53391       -6     
  Branches     6819     6818       -1     
==========================================
- Hits        40933    40926       -7     
- Misses      12227    12229       +2     
+ Partials      237      236       -1     
Flag Coverage Δ
javascript 70.76% <100.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
...ontrols/DndColumnSelectControl/DndFilterSelect.tsx 45.33% <ø> (ø)
...ontrols/DndColumnSelectControl/DndMetricSelect.tsx 41.40% <ø> (ø)
...ontrols/FilterControl/AdhocFilterControl/index.jsx 57.69% <ø> (ø)
.../FilterControl/AdhocFilterPopoverTrigger/index.tsx 80.76% <ø> (ø)
...ntrols/MetricControl/AdhocMetricPopoverTrigger.tsx 72.30% <ø> (ø)
...mponents/controls/MetricControl/MetricsControl.jsx 42.05% <ø> (ø)
.../controls/DndColumnSelectControl/OptionWrapper.tsx 85.45% <100.00%> (-0.52%) ⬇️
...d/src/explore/components/DatasourcePanel/index.tsx 73.95% <0.00%> (-2.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4960b5e...191fa12. Read the comment docs.

@kgabryje
Copy link
Member Author

/testenv up FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true FEATURE_ENABLE_DND_WITH_CLICK_UX=true

@github-actions
Copy link
Contributor

@kgabryje Ephemeral environment spinning up at http://34.214.208.78:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines -66 to +70
const item: OptionItemInterface = useMemo(
() => ({
dragIndex: index,
type,
}),
[index, type],
);
const [{ isDragging }, drag] = useDrag({
item,
item: {
type,
dragIndex: index,
},
Copy link
Member

Choose a reason for hiding this comment

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

It appears we're a few versions behind react-dnd (now on 14; we're on 11). Apparently the deps can now be given as a param after spec:

image

https://react-dnd.github.io/react-dnd/docs/api/use-drag

Might be a good TODO for when we bump this the next time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good to know!

Copy link
Member

@jinghua-qa jinghua-qa left a comment

Choose a reason for hiding this comment

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

LGTM

reordering.in.column.mov
reordering.in.filters.mov

@kgabryje kgabryje merged commit a547dcb into apache:master Aug 18, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@henryyeh
Copy link
Contributor

🏷️ 2021.31

henryyeh pushed a commit to preset-io/superset that referenced this pull request Aug 19, 2021
…#16322)

* fix(explore): reordering columns with dnd sometimes glitching

* Fix metrics and filters popover being stale after reordering

(cherry picked from commit a547dcb)
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
…#16322)

* fix(explore): reordering columns with dnd sometimes glitching

* Fix metrics and filters popover being stale after reordering
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
…#16322)

* fix(explore): reordering columns with dnd sometimes glitching

* Fix metrics and filters popover being stale after reordering
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset:2021.31 size/S 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[dnd][dnd hybrid] reordering by dnd is not accurate and popover is not matching when the reordering fail
5 participants