On select expand ancestory
Summary: Previously when selecting from the visualiser nothing would happen in the tree if one of the parents was collapsed Reviewed By: lblasa Differential Revision: D43318177 fbshipit-source-id: 7bf9296dec2ca82e3f983b4cf2676ea8741a9d0e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1cd916e414
commit
8cae1f0de6
@@ -157,6 +157,7 @@ const MemoTreeItemContainer = React.memo(
|
|||||||
const id = nextProps.treeNode.id;
|
const id = nextProps.treeNode.id;
|
||||||
return (
|
return (
|
||||||
prevProps.treeNode.id === nextProps.treeNode.id &&
|
prevProps.treeNode.id === nextProps.treeNode.id &&
|
||||||
|
prevProps.treeNode.isExpanded === nextProps.treeNode.isExpanded &&
|
||||||
prevProps.isContextMenuOpen === nextProps.isContextMenuOpen &&
|
prevProps.isContextMenuOpen === nextProps.isContextMenuOpen &&
|
||||||
prevProps.frameworkEvents === nextProps.frameworkEvents &&
|
prevProps.frameworkEvents === nextProps.frameworkEvents &&
|
||||||
prevProps.highlightedNodes === nextProps.highlightedNodes &&
|
prevProps.highlightedNodes === nextProps.highlightedNodes &&
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
return {
|
return {
|
||||||
rootId,
|
rootId,
|
||||||
uiState,
|
uiState,
|
||||||
uiActions: uiActions(uiState),
|
uiActions: uiActions(uiState, nodes),
|
||||||
nodes,
|
nodes,
|
||||||
frameworkEvents,
|
frameworkEvents,
|
||||||
snapshot,
|
snapshot,
|
||||||
@@ -262,7 +262,7 @@ type UIActions = {
|
|||||||
onCollapseNode: (node: Id) => void;
|
onCollapseNode: (node: Id) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
function uiActions(uiState: UIState): UIActions {
|
function uiActions(uiState: UIState, nodes: Atom<Map<Id, UINode>>): UIActions {
|
||||||
const onExpandNode = (node: Id) => {
|
const onExpandNode = (node: Id) => {
|
||||||
uiState.expandedNodes.update((draft) => {
|
uiState.expandedNodes.update((draft) => {
|
||||||
draft.add(node);
|
draft.add(node);
|
||||||
@@ -270,6 +270,14 @@ function uiActions(uiState: UIState): UIActions {
|
|||||||
};
|
};
|
||||||
const onSelectNode = (node?: Id) => {
|
const onSelectNode = (node?: Id) => {
|
||||||
uiState.selectedNode.set(node);
|
uiState.selectedNode.set(node);
|
||||||
|
let cur = node;
|
||||||
|
//expand entire ancestory in case it has been manually collapsed
|
||||||
|
uiState.expandedNodes.update((expandedNodesDraft) => {
|
||||||
|
while (cur != null) {
|
||||||
|
expandedNodesDraft.add(cur);
|
||||||
|
cur = nodes.get().get(cur)?.parent;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCollapseNode = (node: Id) => {
|
const onCollapseNode = (node: Id) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user