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

[Lens] Keyboard-selected items follow user traversal of drop zones #90546

Merged

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Feb 6, 2021

Summary

Fixes #90339

Interaction with field:
field_1

Interaction between dimensions
normal

Interaction when reordering
reorder

Design Questions:

  1. Should we leave the focus ring in the original place of the dragging element? I don't do it here, but maybe I should.
  2. When user selects the workspace as an active drop, we don't display the ghost image at all, only for dimension elements. Is this ok?
  3. A field from datasource panel is copied and not moved, so I decided not to hide it. Let me know your thoughts :)
  4. Maybe for the duplicate in group interaction (and other interactions that will come later on where we don't move the element but copy it) we shouldn't hide the dragging field?
    duplicate

@mbondyra mbondyra added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:Lens v7.12.0 labels Feb 6, 2021
@mbondyra mbondyra requested a review from a team February 6, 2021 10:03
@mbondyra mbondyra requested a review from a team as a code owner February 6, 2021 10:03
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@mbondyra mbondyra changed the title adding a ghost image [Lens] Keyboard-selected items follow user traversal of drop zones Feb 6, 2021
@mbondyra mbondyra force-pushed the lens/dnd_add_ghost_image_to_keyboard_navigation branch 4 times, most recently from 763dc90 to 20b5f37 Compare February 7, 2021 17:06
@mbondyra
Copy link
Contributor Author

mbondyra commented Feb 8, 2021

@elasticmachine merge upstream

/**
* don't display ghost image for the drop element
*/
noGhost?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I find negative props somewhat confusing in components. Maybe others do to?

Especially when passing in false you end up with a double negative when thinking it through and that can throw people (me, at least) for a loop.

Copy link
Contributor Author

@mbondyra mbondyra Feb 9, 2021

Choose a reason for hiding this comment

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

I understand and it makes sense. However, on the other side, this construction allows us to treat displaying a ghost as a default behaviour without passing extra parameter and that's what I was trying to do here. So for most components, I can do <DragDrop draggable .../> and I don't have to add ghost = {true} (or specify a default value in the component). I understand it's a bit on the edge when it comes to readability so I'd like to know the opinion of another person reviewing this 🙏

Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

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

Looks good! I like the effect and when testing with Voice Over I didn't notice anything breaking.

Just one small bug (below) and a small nit/question in the code.

Kind of an odd bug, and might be a browser bug, only in Safari in full screen mode, if I'm moving a dimension to a different drop target but then cancel by pressing esc, Safari exists full screen mode. This doesn't happen in other browsers. And this doesn't happen if I'm reordering and press esc. Maybe an extra event.preventDefault() somewhere can prevent this?

@mbondyra mbondyra force-pushed the lens/dnd_add_ghost_image_to_keyboard_navigation branch from b085a7d to e19f9ad Compare February 9, 2021 08:48
@mbondyra
Copy link
Contributor Author

mbondyra commented Feb 9, 2021

Thanks for the review @myasonik! I fixed the bug with your suggestion, e.stopPropagation()

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@flash1293
Copy link
Contributor

These failures don't seem related, testing again.

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

The feature LGTM once the PR is green, this is a smart way to implement it. Tested in Chrome and Firefox and it renders fine

I think it's worth adding a unit test to the drag_drop tests to verify whether the ghost image is put correctly into the context and rendered correctly on the active target.

Left a comment about the prop name, but it's not a big deal IMHO.

/**
* don't display ghost image for the drop element
*/
noGhost?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong feeling here, but we could call the prop ghost and treat undefined as true:

{(ghost || typeof ghost === 'undefined') &&
      dragging?.ghost &&
      activeDropTarg...

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@MichaelMarcialis
Copy link
Contributor

This looks awesome, @mbondyra! Here are my responses to your questions.

Should we leave the focus ring in the original place of the dragging element? I don't do it here, but maybe I should.

No, I think leaving behind an empty focus ring in the original location when changing dimensions would end up being a distraction. If anything, it probably makes the most sense to keep the focus ring around the ghosted item to make it very apparent where the item is moving. Here's an example below.

Frame 122

When user selects the workspace as an active drop, we don't display the ghost image at all, only for dimension elements. Is this ok?

Ideally, I'd love to see the ghost behavior be consistent, even when dropping a field on the workspace. Is it possible to add the ghosted field to the top right of the workspace when it is the currently selected drop zone?

A field from datasource panel is copied and not moved, so I decided not to hide it. Let me know your thoughts :)

Correct. Since the field isn't being removed from that list, I think it makes sense not to hide it.

Maybe for the duplicate in group interaction (and other interactions that will come later on where we don't move the element but copy it) we shouldn't hide the dragging field?

I'm OK leaving it as is for the moment. It might be more confusing on the user's part to see the ghost in the "add" drop zone but then also seeing the item in its original spot simultaneously.

Otherwise, here's some additional comments from my review:

  • Would it be possible to hide the tooltip icon for the ghost version of fields being actively dragged?

Frame 123

  • The ghost vertical offsets for the "add" drop zones and the "replace" drop zones appear to be different. Can these both be a consistent 8px vertical offset?

Frame 124

  • There is a double border occurring in the workspace when in drag mode (keyboard and mouse). One border is the panel and the other is the drop zone. Is it possible to just stylize the panel border during a drag event rather than adding a new border inside the panel?

Frame 125

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@mbondyra
Copy link
Contributor Author

Hey @MichaelMarcialis I've corrected all the things you mentioned except for the workspace double border - everytime I am applying it in some way, some other thing breaks and I want to merge this branch before FF on Tuesday. Are you ok with merging this as it is and then correcting the double border in separate PR? 🙏

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

LGTM, tested in Firefox!

@@ -416,8 +446,13 @@ const DropInner = memo(function DropInner(props: DropInnerProps) {
setActiveDropTarget(undefined);
setKeyboardMode(false);
};

// const shouldShowGhost = isActiveDropTarget && dropType !== 'reorder';
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented code

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

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

Sorry, I found a bug caused by this PR: the entire workspace panel is empty in Firefox.

@elastic elastic deleted a comment from kibanamachine Feb 11, 2021
@@ -34,6 +33,8 @@
// Color the whole panel instead
background-color: transparent !important; // sass-lint:disable-line no-important
border: none !important; // sass-lint:disable-line no-important
width: 100%;
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why this behavior changed, can you explain?

Copy link
Contributor Author

@mbondyra mbondyra Feb 11, 2021

Choose a reason for hiding this comment

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

Yes, so we have this style:

.lnsWorkspacePanelWrapper .lnsWorkspacePanelWrapper__pageContentBody > * {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;

that before was applied directly to .lnsWorkspace. Now, when I added .lnsDragDrop__container as a parent of the element, .lnsDragDrop__container got the styles above so I needed to ensure the child (.lnsWorkspace) was "spread" inside.

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Thanks for making those changes, @mbondyra. Let me know if you want me to create that separate issue for the double border.

I left one small suggestion. Otherwise, this looks good to me. Approving now so I don't hold you up further.

x-pack/plugins/lens/public/drag_drop/drag_drop.scss Outdated Show resolved Hide resolved
Co-authored-by: Michael Marcialis <michael@marcial.is>
@mbondyra
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 892.3KB 896.4KB +4.1KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mbondyra
Copy link
Contributor Author

@wylieconlon I want to merge this one before FF so I'lll merge it despite your 'changes requested' - I addressed your request already, hope it's fine!

@mbondyra mbondyra merged commit 0ee7be1 into elastic:master Feb 15, 2021
@mbondyra mbondyra deleted the lens/dnd_add_ghost_image_to_keyboard_navigation branch February 15, 2021 12:03
jloleysens added a commit to jloleysens/kibana that referenced this pull request Feb 15, 2021
…ndition-for-hiding-recommded-allocation

* 'master' of github.com:elastic/kibana:
  [Discover] Fix toggling multi fields from doc view table (elastic#91121)
  [ML] Data Frame Analytics: ROC Curve Chart (elastic#89991)
  skip flaky suite (elastic#86948)
  skip flaky suite (elastic#91191)
  Fix date histogram time zone for rollup index (elastic#90632)
  [Search Source] Fix retrieval of unmapped fields; Add field filters (elastic#89837)
  [Logs UI] Use useMlHref hook for ML links (elastic#90935)
  Fix values of `products.min_price` field in Kibana sample ecommerce data set (elastic#90428)
  [APM] Darker shade for Error group details labels (elastic#91349)
  [Lens] Adjust new copy for 7.12 (elastic#90413)
  [ML] Unskip test. Fix modelMemoryLimit value. (elastic#91280)
  [Lens] Fix empty display name issue in XY chart (elastic#91132)
  [Lens] Improves error messages when in Dashboard (elastic#90668)
  [Lens] Keyboard-selected items follow user traversal of drop zones (elastic#90546)
  [Lens] Improves ranking feature in Top values (elastic#90749)
  [ILM] Rollover min age tooltip and copy fixes (elastic#91110)

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Keyboard-selected items should follow user traversal of drop zones
7 participants