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): fix undefined error when using dnd #16020

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Aug 2, 2021

SUMMARY

When user tried to drag and drop value from a control to a different control of the same type, an undefined error occurred. The root of the issue was in reordering logic - in order the rearrange values, control's dnd handler had to accept a given drag item type. However if there were more controls of the same type in control panel, user could drag them to the other control, which wasn't handled in any way. This PR fixes the issue by changing control's dnd type from a generic one (like "Column", "Metric" etc.) to a more specific one (old type concatenated with control's name and label to ensure uniqueness).
In the future, we'll enhance the DnD experience by allowing user to drag and drop items across different controls (instead of prohibiting it). However, that will require deeper, riskier changes, so for now let's just fix the "undefined" error with this PR.
While I was at it, I introduced a few simple performance improvements - mostly wrapping stuff in useCallbacks and useMemos.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: see #16009

After:
https://user-images.githubusercontent.com/15073128/127839347-f0e4e9af-c10c-4e8c-a426-03987e8180d7.mov

TESTING INSTRUCTIONS

  1. Enable drag and drop
  2. Create a chart which has multiple controls of the same type, for example table or pivot table
  3. Add values to controls of the same type (e.g Metric and Percentage Metric in Table, or Columns and Rows in Pivot Table)
  4. Try to drag a value from 1 control to the other.
  5. Verify that nothing happened and no "undefined" error is shown

ADDITIONAL INFORMATION

CC: @jinghua-qa @junlincc

@codecov
Copy link

codecov bot commented Aug 2, 2021

Codecov Report

Merging #16020 (b452de8) into master (46188c1) will decrease coverage by 0.09%.
The diff coverage is 52.89%.

❗ Current head b452de8 differs from pull request most recent head e71b5f6. Consider uploading reports for the commit e71b5f6 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16020      +/-   ##
==========================================
- Coverage   77.03%   76.94%   -0.10%     
==========================================
  Files         989      990       +1     
  Lines       52413    52491      +78     
  Branches     6634     6642       +8     
==========================================
+ Hits        40378    40389      +11     
- Misses      11812    11878      +66     
- Partials      223      224       +1     
Flag Coverage Δ
javascript 71.49% <36.68%> (-0.03%) ⬇️
presto ?
sqlite ?

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

Impacted Files Coverage Δ
...s/controls/MetricControl/MetricDefinitionValue.jsx 80.00% <ø> (ø)
...mponents/controls/MetricControl/MetricsControl.jsx 82.94% <ø> (+0.48%) ⬆️
superset/security/manager.py 91.90% <ø> (ø)
...ontrols/DndColumnSelectControl/DndFilterSelect.tsx 45.07% <26.98%> (-0.46%) ⬇️
...ontrols/DndColumnSelectControl/DndMetricSelect.tsx 42.06% <30.90%> (+1.02%) ⬆️
...ontrols/DndColumnSelectControl/DndColumnSelect.tsx 61.11% <38.46%> (-3.48%) ⬇️
...nents/controls/MetricControl/AdhocMetricOption.jsx 75.00% <50.00%> (+2.27%) ⬆️
...erset-frontend/src/datasource/DatasourceEditor.jsx 74.15% <66.66%> (-0.85%) ⬇️
superset/connectors/sqla/utils.py 87.50% <87.50%> (ø)
superset/views/datasource.py 90.12% <95.00%> (+1.59%) ⬆️
... and 12 more

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 46188c1...e71b5f6. Read the comment docs.

@kgabryje kgabryje closed this Aug 2, 2021
@kgabryje kgabryje reopened this Aug 2, 2021
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, thanks for the fix! For future PRs it might be better to separate into two separate PRs; one with just the fix and another with the perf improvements (easier for the lazy reviewers like myself :D)

@junlincc
Copy link
Member

junlincc commented Aug 2, 2021

/testenv up ENABLE_EXPLORE_DRAG_AND_DROP=true

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2021

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

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

LGTM

@kgabryje kgabryje merged commit 3061b6a into apache:master Aug 2, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2021

Ephemeral environment shutdown and build artifacts deleted.

@junlincc junlincc added the #bug:blocking! Blocking issues with high priority label Aug 2, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.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 #bug:blocking! Blocking issues with high priority size/XL 🚢 1.3.0
Projects
None yet
5 participants