* Set the layout to focus on the given node. * @param nodeId The id of the node that is being focused.
(nodeId: string)
| 1228 | * @param nodeId The id of the node that is being focused. |
| 1229 | */ |
| 1230 | focusNode(nodeId: string) { |
| 1231 | if (this.focusedNodeId === nodeId) return; |
| 1232 | let layoutNode = findNode(this.treeState?.rootNode, nodeId); |
| 1233 | if (!layoutNode) { |
| 1234 | const ephemeralNode = this.getter(this.ephemeralNode); |
| 1235 | if (ephemeralNode?.id === nodeId) { |
| 1236 | layoutNode = ephemeralNode; |
| 1237 | } else { |
| 1238 | console.error("unable to focus node, cannot find it in tree", nodeId); |
| 1239 | return; |
| 1240 | } |
| 1241 | } |
| 1242 | const action: LayoutTreeFocusNodeAction = { |
| 1243 | type: LayoutTreeActionType.FocusNode, |
| 1244 | nodeId: nodeId, |
| 1245 | }; |
| 1246 | |
| 1247 | this.treeReducer(action); |
| 1248 | } |
| 1249 | |
| 1250 | focusFirstNode() { |
| 1251 | const leafOrder = this.getter(this.leafOrder); |
no test coverage detected