Hi @walter, I have a few questions regarding the accessibility navigation in the structured diagram. The overall navigation seems to be working fine, and I see that we’re relying on _findNearestTowards based on the arrow key pressed.
However, there are a few cases where the behavior seems inconsistent:
When nodes are close to each other, navigation works as expected.
When two nodes are near each other, the link is skipped, and focus moves directly to the other node.
In a scenario with three sibling nodes, if one is positioned near the parent, pressing the left arrow sometimes shifts focus to the parent instead of a sibling.
To ensure more consistent and predictable navigation, we may need a more standardized approach, such as breadth-first (BFS) traversal.
Yes, that’s possible. You can find an implementation of that in the DrawCommandHandler extension, which has a mode that implements the standard tree view control navigation and expand/collapse functionality using arrow keys.
Hi @walter, I explored the DrawCommandHandler and looked into the sample provided, but I wasn’t able to fully understand or relate it to our use case.
We’re currently using the sample code you shared earlier, and overall it’s working well—except for the _findNearestTowards method. We’re facing issues specifically with its navigation logic.
Would it be possible for you to provide a sample implementation of _findNearestTowards that uses BFS (Breadth-First Search) for node navigation?
For example, imagine a parent node with three children, and each child contains interactive elements. When pressing the Down Arrow, the focus should move to the leftmost child. Then, pressing the Right Arrow should move the focus to the sibling nodes (middle or right child), and pressing Left Arrow should navigate in the opposite direction. Essentially, it should traverse children on the same level before moving deeper into the hierarchy.
A sample in that direction would be really helpful!
Did you try the “tree” arrowKeyBehavior? That’s meant to implement the typical tree-view-like behavior for arrow keys, which is basically DFS, but it’s what many people are used to when trees are linearized. But a separate BFS behavior sounds like a reasonable alternative.
Yes, @walter, I tried arrowKeyBehavior, and it looks like it uses the same navigation method — _findNearestPartTowards. We need a more consistent navigation flow.
Yes, I tried it. First, it goes to Beta, then Gamma, followed by Delta, Epsilon, and finally Epsilon1, and then moving to the right-side nodes from top to bottom. However, I still didn’t observe any BFS-like consistency in the navigation flow.
As I said, the standard arrow key behavior in regular tree-view components supports a depth-first traversal as if the whole tree had been flattened into a list. What you propose sounds much simpler and should be easy to implement.
Hi @walter,
Any references or guidance would be greatly appreciated.
We’re implementing a use case involving breadth-first traversal combined with keyboard navigation. Specifically, we want to enable navigation using the arrow keys::
Left/Right arrows should move the selection horizontally between sibling nodes (e.g., between nodes B and C at the same level).
Up/Down arrows should navigate vertically to parent and child nodes (e.g., from B up to A, or down to D).
The diagram below illustrates the structure we’re working with. Any suggestions on how best to achieve this in GoJS?
I have one more question, @walter. I’ve noticed that the canvas (diagram) itself always appears selected. When we navigate between nodes using the arrow keys, the node selection updates correctly, but the diagram background still seems to remain selected.
Is there a way to clear or prevent the diagram canvas from staying selected during node navigation?
This issue only occurs when we’re navigating using the arrow keys for accessibility, @walter.
Do you think it’s still related to the article you mentioned above?
We are working on the canvas and attempting to add adornments to the nodes within it. Could this be causing the issue?
Hi @walter,
Would it be possible to integrate the BFS changes into the earlier code you shared for navigating within Nodes and Links—specifically into their GraphObjects—using Enter, Escape, and Shift+Enter, as described in this post?
Right now, it’s a bit confusing for us to integrate both. What we’re looking for is a unified approach that combines the BFS logic you provided with the navigation mechanism into GraphObjects and handling of loops, as you outlined in the same thread - Need more insight on a11y / accessibility - #21 by vinesh
If possible, could you provide a single version of the code with both changes integrated? Otherwise, we’re happy to try a shot at merging them ourselves.
There’s a limit to how much custom coding we’ll do for free as part of your support. We do have many other customers who also want help with their apps. I believe you can do it, but it will take some thought, study, and experimentation.