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 #10369: icons of custom tree view row are not visible on mouse hover #10375

Merged
merged 4 commits into from
Nov 17, 2021

Conversation

EstherPerelman
Copy link
Contributor

@EstherPerelman EstherPerelman commented Nov 3, 2021

Signed-off-by: Esther Perelman [email protected]

What it does

Fix #10369 by replacing update to forceUpdateGrid call on mouseover event since the update request not activate the rendering of the grid by react (it doesn't pass the internal React.Grid _calculateChildrenToRender function because of old caches)

How to test (also for buggy result)

  1. install tree-view-sample extension of vscode-extensions-samples on Theia (you can easily download my custom-view-sample.zip )
  2. from the top menu select View -> Open View -> Packege Explorer
  3. hover with the mouse on the rows
  4. good result: see edit icon for each row on hover, bad result: see edit icon only on selecting row

Review checklist

Reminder for reviewers

@EstherPerelman EstherPerelman force-pushed the hover-tree-issue branch 3 times, most recently from 116c597 to 84b8445 Compare November 3, 2021 10:02
@msujew msujew added tree issues related to the tree (ex: tree widget) vscode issues related to VSCode compatibility labels Nov 3, 2021
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

Thanks @EstherPerelman for taking care of this.

While this works on a surface level, I noticed some issues with debouncing the forced update here. Especially when swiftly moving over the tree nodes (the hover marker will lag behind a few frames). I tried the change below and it seems to fix the issue as well. Are there any issues with this approach that I didn't notice?

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

@EstherPerelman I still feel like debouncing here is not necessary and only leads to artifacts when swiftly moving the cursor over the tree nodes. Notice how the icon always lags behind the cursor, while the background highlighting correctly moves with the cursor:

2021-11-04.16-26-39.mp4

When removing the debounce, the feature continues to work as expected, without any of the artifacts, at least in my tests. What speaks in favor of debouncing the forced update?

@EstherPerelman
Copy link
Contributor Author

EstherPerelman commented Nov 4, 2021

What speaks in favor of debouncing the forced update?

@msujew I added the debounce because in my test(without the debounce) the edit icon wasn't clickable (- didn't show the information message on the bottom right as happens now),
Also the icon not always appears onMouseOver event as you can see in the video:

vscode.Theia.Browser.Example.-.Google.Chrome.2021-11-05.00-54-23.mp4

Notice how the icon always lags behind the cursor, while the background highlighting correctly moves with the cursor

I changed the debounce wait value to 1ms, It seems to be better WDYS?

@msujew
Copy link
Member

msujew commented Nov 9, 2021

@EstherPerelman Alright, thank you for the explanation. That makes me believe that forcing an update here is the wrong direction. I have another idea:

  1. Add this rule to the tree.css file:
.theia-TreeNode:not(:hover):not(.theia-mod-selected) .theia-tree-view-inline-action {
    display: none;
}
  1. Always render the inline commands by removing these lines of code:
    if (this.model.selectedNodes.every(selected => selected.id !== node.id) && node.id !== this.hoverNodeId) {
    return false;
    }
  2. Add the ACTION_ITEM class constant (imported from @theia/core/lib/browser/widgets/widget) to the inline command classes:
    const className = [TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS, icon, 'theia-tree-view-inline-action'].join(' ');
  3. Remove the forced update on the setHoverNodeId method.

That way we always render the inline commands to html, but don't display them if it's not necessary. What do you think about that?

@EstherPerelman
Copy link
Contributor Author

That way we always render the inline commands to html, but don't display them if it's not necessary. What do you think about that?

@msujew, in the first time I looked at this code area I wondered why the hover was not implemented with css... but preferred not to touch the existing code, with your suggestion it's working perfect and the code is more reasonable

@msujew
Copy link
Member

msujew commented Nov 10, 2021

@EstherPerelman Yeah, it seems to be some ancient code that's been there since the first version of the inline commands and has never been touched since. The new approach looks way better.

@colin-grant-work @vince-fugnitto Any possible regressions that you might see due to the CSS approach compared to using setHoverNodeId? If not, I would approve this PR soonish.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

I confirmed that the behavior works well on hover 👍

@@ -40,3 +40,7 @@
margin-bottom: 10px;
margin-left: 17px;
}

.theia-TreeNode:not(:hover):not(.theia-mod-selected) .theia-tree-view-inline-action {
Copy link
Member

Choose a reason for hiding this comment

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

@msujew should we prefix the entry with .theia-tree-view as not to potentially affect other views and keep the styling specific to the plugin-system?

Suggested change
.theia-TreeNode:not(:hover):not(.theia-mod-selected) .theia-tree-view-inline-action {
.theia-tree-view .theia-TreeNode:not(:hover):not(.theia-mod-selected) .theia-tree-view-inline-action {

Copy link
Member

Choose a reason for hiding this comment

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

Sure, sounds like a good idea 👍

@EstherPerelman
Copy link
Contributor Author

Hi @vince-fugnitto @msujew I pushed the change, Can you merge it soonish?

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

LGTM! I just reconfirmed that everything works as expected.

I will probably merge this tomorrow, if there are no objections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tree issues related to the tree (ex: tree widget) vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

the action icon of tree-view extensions with menu icon contribution doesn't show up on hover
3 participants