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

[Dashboard][Collapsable Panels] Respond to touch events #204225

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Dec 13, 2024

Summary

Adds support to touch events. The difference between these ones and mouse events is that once they are active, the scroll is off (just like in the current Dashboard)

touch.mp4

Fixes #202014

@mbondyra mbondyra added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Project:Collapsable Panels Related to the project for adding collapsable sections to Dashboards. labels Dec 13, 2024
@mbondyra mbondyra force-pushed the collapsable_panels/touch branch 3 times, most recently from a28959b to 60a0bff Compare December 13, 2024 14:50
@mbondyra mbondyra force-pushed the collapsable_panels/touch branch from 60a0bff to d34d868 Compare December 13, 2024 14:50

const setDragHandles = useCallback(
(dragHandles: Array<HTMLElement | null>) => {
if (gridLayoutStateManager.accessMode$.getValue() !== 'EDIT') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might be missing something here and maybe there's a reason to put it directly in the onTouchStart etc callbacks?

Copy link
Contributor

Choose a reason for hiding this comment

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

So the reason I had it in the onMouseDown is that the drag handles don't always get unmounted on view mode change - specifically, when it comes to embeddables, this occurs when the panel title is acting as the drag handle. So if we don't cancel out drag events on mouse down and/or touch start, the user can drag panels around in view mode:

Screen.Recording.2024-12-18.at.1.26.45.PM.mov

@mbondyra mbondyra marked this pull request as ready for review December 13, 2024 15:41
@mbondyra mbondyra requested a review from a team as a code owner December 13, 2024 15:41
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@Heenawter Heenawter self-requested a review December 16, 2024 15:38
Comment on lines +85 to +86
handle.addEventListener('touchstart', onTouchStart, { passive: false });
handle.addEventListener('touchend', onTouchEnd, { passive: true });
Copy link
Contributor

@Heenawter Heenawter Dec 18, 2024

Choose a reason for hiding this comment

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

Do we need seperate onTouchStart + onTouchEnd callbacks defined? It looks like we could modify the existing onMouseDown callback a bit and use it for the touchstart event listener too, for example? They're more-or-less doing the same thing.

We could rename them to onDragStart and onDragEnd rather than tying the name to a mouse action 🤷

Comment on lines 245 to 246
// `shouldAutoScroll` is set to false because we don't want the screen to scroll when dragging/resizing the items
calculateUserEvent(e, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm... I'm still getting some strange scrolling at times - not really sure what is causing it, but it's like the panel gets stuck 🤔

Screen.Recording.2024-12-18.at.1.35.25.PM.mov

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #18 / EQL Tab rendering should render the timeline table

Metrics [docs]

✅ unchanged

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Project:Collapsable Panels Related to the project for adding collapsable sections to Dashboards. release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dashboard][Collapsable Panels] Respond to touch events
3 participants