(currentNode: Node | undefined | null, event: MouseEvent)
| 902 | * get the closest clickable node |
| 903 | */ |
| 904 | export const getClosestClickableNode = (currentNode: Node | undefined | null, event: MouseEvent) => { |
| 905 | let node = currentNode |
| 906 | while (node) { |
| 907 | // check if the current node is clickable |
| 908 | let canClick = node.canClick(event) |
| 909 | const lockedNode = getClosestNode(node, n => { |
| 910 | // if the current node is locked, start searching from the parent node |
| 911 | return !n.locked |
| 912 | }) |
| 913 | if (lockedNode && lockedNode.getId() !== node.getId()) { |
| 914 | canClick = false |
| 915 | } |
| 916 | if (canClick) { |
| 917 | break |
| 918 | } |
| 919 | // for unclickable nodes, continue searching up |
| 920 | node = node.parent |
| 921 | } |
| 922 | return node |
| 923 | } |
| 924 | |
| 925 | /** |
| 926 | * ensure the node is a Node instance |
no test coverage detected