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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/main/browser/style/tree.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@
margin-bottom: 10px;
margin-left: 17px;
}

.theia-tree-view .theia-TreeNode:not(:hover):not(.theia-mod-selected) .theia-tree-view-inline-action {
display: none;
}
21 changes: 2 additions & 19 deletions packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { MenuPath, MenuModelRegistry, ActionMenuNode } from '@theia/core/lib/com
import * as React from '@theia/core/shared/react';
import { PluginSharedStyle } from '../plugin-shared-style';
import { ViewContextKeyService } from './view-context-key-service';
import { Widget } from '@theia/core/lib/browser/widgets/widget';
import { ACTION_ITEM, Widget } from '@theia/core/lib/browser/widgets/widget';
import { Emitter, Event } from '@theia/core/lib/common/event';
import { MessageService } from '@theia/core/lib/common/message-service';
import { View } from '../../../common/plugin-protocol';
Expand Down Expand Up @@ -327,9 +327,6 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
}

protected renderTailDecorations(node: TreeViewNode, props: NodeProps): React.ReactNode {
if (this.model.selectedNodes.every(selected => selected.id !== node.id) && node.id !== this.hoverNodeId) {
return false;
}
return this.contextKeys.with({ view: this.id, viewItem: node.contextValue }, () => {
const menu = this.menus.getMenu(VIEW_ITEM_INLINE_MENU);
const arg = this.toTreeViewSelection(node);
Expand All @@ -349,27 +346,13 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
if (!icon || !this.commands.isVisible(node.action.commandId, arg) || !this.contextKeys.match(node.action.when)) {
return false;
}
const className = [TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS, icon, 'theia-tree-view-inline-action'].join(' ');
const className = [TREE_NODE_SEGMENT_CLASS, TREE_NODE_TAIL_CLASS, icon, ACTION_ITEM, 'theia-tree-view-inline-action'].join(' ');
return <div key={index} className={className} title={node.label} onClick={e => {
e.stopPropagation();
this.commands.executeCommand(node.action.commandId, arg);
}} />;
}

protected hoverNodeId: string | undefined;
protected setHoverNodeId(hoverNodeId: string | undefined): void {
this.hoverNodeId = hoverNodeId;
this.update();
}

protected createNodeAttributes(node: TreeNode, props: NodeProps): React.Attributes & React.HTMLAttributes<HTMLElement> {
return {
...super.createNodeAttributes(node, props),
onMouseOver: () => this.setHoverNodeId(node.id),
onMouseOut: () => this.setHoverNodeId(undefined)
};
}

protected toContextMenuArgs(node: SelectableTreeNode): [TreeViewSelection] {
return [this.toTreeViewSelection(node)];
}
Expand Down