-
Notifications
You must be signed in to change notification settings - Fork 8.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
[Lens] Implement drag and drop between layers #132018
Conversation
d5f8bb1
to
acb4737
Compare
914fb19
to
94a9009
Compare
e594ff0
to
a60a707
Compare
f2ffe72
to
bf4644a
Compare
46bcda1
to
661f036
Compare
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
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.
Wow @mbondyra , this looks like the culmination of a huge effort! Everything I tested works great. It's fun to have a tour of code I haven't seen before.
Ran out of time today, so I'm leaving a partial review which I can pick back up on Monday.
x-pack/plugins/lens/public/xy_visualization/visualization_helpers.tsx
Outdated
Show resolved
Hide resolved
if (!targetLayer) { | ||
return props.prevState; | ||
} |
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.
When does this condition occur? I can't think of a context within the UI where a drop occurs outside the context of a layer...
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.
So I am actually not sure how to tackle these kind of problems nicely.
I refer to the problems when
- we pass some kind of
id
of object to the function - We then look up the object with this
id
in an object or find it an array - We're sure that the object exist, but typescript will complain...
So we either have to force it with !
or make a check if (obj[id]) return
or throw an error.
Sometimes it happens in Lens that something is implemented in desynchronized way (for example switching layers) and then actually the impossible happens so I got a habit of checking if something exists even if I am sure it is so at least the editor doesn't break for the user 😅 . I would be happy to have a conversation about how to tackle these cases smarter 🙂
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.
You've articulated the dilemma well. Thinking out loud here.
When we make code robust to situations that should never occur it sometimes creates harder-to-find bugs than if we just let the code obviously crash and burn.
On the other hand, as a user, I don't want a minor (possibly inconsistent) bug to become so disruptive that the application is no longer useful (or worse, that I lose my work).
Thinking about this drag-and-drop case, I agree that it seems like the handling should be bullet-proof because, like you say, the impossible could happen and the best thing for the user is probably to shove it under the rug.
If I'm dealing with a different instance of the same pattern you described I might feel differently. For example, if a visualization I'm expecting to be in the visualizationMap
isn't present, that's a big enough issue that I think the best thing for the user is to make the problem obvious so that we catch it early before the release.
And maybe our release cadence and development process inform these decisions, too. For example, maybe obvious bugs become more attractive with a slow release schedule because we have a long time to catch things before actually putting software in front of our users.
Someone must have written a book about this. It could be a good discussion to have as a team.
But, I think how you're doing it in this case makes sense. 👍
x-pack/plugins/lens/public/xy_visualization/visualization.test.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/xy_visualization/visualization.test.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/indexpattern_datasource/operations/time_scale_utils.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/indexpattern_datasource/operations/layer_helpers.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/index.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.ts
Outdated
Show resolved
Hide resolved
...lugins/lens/public/indexpattern_datasource/dimension_panel/droppable/on_drop_handler.test.ts
Outdated
Show resolved
Hide resolved
49fb2d6
to
39b2ea4
Compare
39b2ea4
to
664f6d4
Compare
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.
Looked through everything now. No further comments on my part 👍
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Public APIs missing comments
Async chunks
Public APIs missing exports
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: |
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.
This works fine Marta! I cant find any regression, great enhancement 👏
Summary
Fixes #90441
Enhances drag and drop to be able to move between layers.
It's not as big as it seems, most of it is tests and refactoring.
demo.mov
Refactoring
getDropProps
andonDrop
- the params were consolidated tosource
,target
and the others.isOperationFromCompatibleGroup
Points of tests - I paid attention to those edgecases, let me know if I might have skipped something
a. How focus is placed (a11y)
b. Announcements