-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat: Implement drag and drop for metrics #13575
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13575 +/- ##
==========================================
- Coverage 77.53% 73.19% -4.35%
==========================================
Files 904 604 -300
Lines 45986 21529 -24457
Branches 5552 5682 +130
==========================================
- Hits 35657 15758 -19899
+ Misses 10195 5636 -4559
- Partials 134 135 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do still need that ghost button to indicate users can drop more metrics/columns. |
re the + button: I think having a secondary way to add metrics besides dragging and dropping is still important especially when considering accessibility. Having a simple click button/action provides users that may have some physical disability (whether temporary, situational or permanent) a way to complete the action more easily. Can the ghost button persist even when the field is populated with a metric(s)? |
Hi @Steejay thanks for chiming in. I'm afraid that click-to-select will not support some of the new advanced features we are adding e.g. hierarchy at all. from business standpoint, we are also not gonna invest in maintaining two sets of feature that basically do the same thing. there are more reasons why we need to completely move away from select, comments can be found in Can the ghost button persist even when the field is populated with a metric(s)? |
If users can click the persistent ghost button to add an item, then the "+" button on the right corner would not be needed. |
We should replace all the metric-like target control, such as |
Some corner issue in title dnd-metric-issue.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, for the POC.
no need to worry about it, those issues will all be addressed in refactoring and redesign. |
Reason why we may need the blue button -> accessibility It is not about where or what to click. The goal is to solve these two above within dnd, and get rid of click-to-select!!! |
@kgabryje please bumping the latest superset-ui to the main repo. |
@junlincc I don't understand why the goal is get rid of click-to-select, though. As I responded in the earlier PR, there seems to be a counter-argument to everything you mentioned. Hierarchical columns sounds like a very advanced feature that I'm not even sure what it is or why we need it, but I'd imagine we could get something working in a popover eventually. Have we heard from designers that it is not possible to add these features without drag & drop? Re: accessibility, it's more than just colorblind and visual-impairment, but also easiness to interact. As @Steejay mentioned, DnD simply isn't possible for some users in certain scenarios (e.g. people with poor motor control). An DnD only UI will never achieve the same level of accessibility than a clickable Ui. |
@ktmud all your counter arguments make sense. we have been constantly balancing requests for fixing broken NVD3 charts vs adding new Echarts, fixing broken FilterBox vs enhancing new native filter. We all have the same goal which is to provide the best UX to our users(i take back my statement of 'our goal is to get rid of select') It's the divided attention or lack of focus stopping us from getting to the ultimate goal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a pending review from last night - leaving the comments here as ideas for future PRs.
.map(metric => | ||
(metric as AdhocMetric).column | ||
? (metric as AdhocMetric).column.column_name | ||
: (metric as ColumnMeta).column_name || metric, | ||
) | ||
.filter(name => name && typeof name === 'string') | ||
.every(name => columnNames.has(name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add type guards for the types in value
to be able to separate between the different metrics types (string | AdhocMetric | ColumnMeta
). We could then add a getMetricName(metric)
helper function which would return the name based on which type it is.
import { logging, SupersetClient, t } from '@superset-ui/core'; | ||
import { ColumnMeta, Metric } from '@superset-ui/chart-controls'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bycatch: I believe Metric
is originally defined in @superset-ui/core
(probably better to import from there, as I'm unsure why it's exported by @superset-ui/chart-controls
)
@junlincc @ktmud @mihir174 I like the idea of displaying the ghost button to indicate that the user can drop more columns and metrics. However, I feel that it requires a design input as in my opinion it looks a bit strange when we display values and the ghost button in current form. Details like misaligned "+" and "x" buttons, maybe a dashed border might need some polishing to make the component look more appealing. WDYT? |
However, if you think that the ghost button looks fine as it is, I'll open a PR with that change |
FWIW, I think the ghost button is awesome, much better than the plus button, both aesthetically and functionally (but I agree it needs some polish). |
Another potential improvement is to display coloured dash border when user starts dragging an element, not only when it's hovering over a control component. That might help users understand where they can drop columns and metrics Screen.Recording.2021-03-12.at.11.43.40.mov |
@junlincc Good idea! I'll try to include that in a follow-up PR |
I like this design. |
Yeah, me too. I was just thinking to myself that when fully and properly implemented (good scrolling/filtering on column/metric tab, highlighting during dragging etc), DND offers so many small UX improvements that it make the select feature seem almost confusing and awkward. Not sure what I said a few weeks ago, but after careful deliberation, I vote for deprecating the select control as soon as possible :) |
There is a movement called Inclusive Design I'm not sure if you have heard of. Basically it says instead of thinking things like accessibility as an investment that benefits only a small fraction of users, we should have the mindset of being inclusive from the very beginning. It doesn't necessary slow you down in the process, but will help you reach to more users. I have yet to see how supporting click-to-select would slow things down or introduce the so-called 2x maintenance cost. If we want to get rid of it because it doesn't sit well with the DnD experience, that's fine, but in terms of code maintenance, I find it hard to believe it'd be 2x the effort. |
* Convert MetricsControl to functional component * Implement drag and drop for metrics * Implement customizable placeholder for DndSelectLabel
SUMMARY
This PR implements creating adhoc metrics by dragging columns and saved metrics from datasource panel to metrics control.
When user drops a column or saved metric, a popover opens pre-filled with values - if a metric was dropped, a "Saved metrics" tab is open by default with a proper metric selected, otherwise "Simple" tab is open with a column selected.
The old functionality of creating a metric by clicking a "plus" button has ben removed.
To use the feature, enable
ENABLE_EXPLORE_DRAG_AND_DROP
feature flag and use changes from apache-superset/superset-ui#1004.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2021-03-11.at.13.57.14.mov
TEST PLAN
ADDITIONAL INFORMATION
CC: @villebro @junlincc @zhaoyongjie