Skip to content

fix: focus the tree, not its panel, for the Object Explorer shortcut - #10294

Open
dpage wants to merge 2 commits into
pgadmin-org:masterfrom
dpage:fix/object-explorer-shortcut-focus
Open

fix: focus the tree, not its panel, for the Object Explorer shortcut#10294
dpage wants to merge 2 commits into
pgadmin-org:masterfrom
dpage:fix/object-explorer-shortcut-focus

Conversation

@dpage

@dpage dpage commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The Object Explorer shortcut, Shift+Alt+B by default, is meant to put the keyboard into the tree so that the arrow keys then move between nodes. It calls focus() on the rc-dock tab pane that wraps the tree, and that pane is a plain div with no tabindex, so it cannot take focus at all. The result is that the shortcut selects a node and leaves focus wherever it already was, which for anybody navigating by keyboard looks like nothing happening.

Nothing needs a tabindex adding, as I first assumed. The tree react-aspen renders inside the panel already carries tabindex="-1", so it is focusable programmatically; the fix is simply to aim at it, falling back to the panel when the tree is not there so that the behaviour cannot end up worse than it is today.

const panel = document.querySelector('[id="id-object-explorer"]');
(panel?.querySelector('.file-tree') ?? panel)?.focus();

I found this whilst reviewing #10254, which is what made it visible: once the Object Explorer can be collapsed, a shortcut that silently fails to focus it is much easier to notice.

Testing

web/regression/javascript/browser/keyboard_left_tree_spec.js covers focus landing on the tree, the fallback when no tree is present, and the case where the Object Explorer is not in the DOM at all. The first of those fails against the current code.

I also drove it in a browser rather than trusting the unit test: starting from a collapsed Object Explorer with focus on document.body, pressing Shift+Alt+B now reveals the panel and leaves document.activeElement as the file-tree element, where before it stayed on body.

No release note entry, per the usual practice of batching those shortly before release.

The Object Explorer shortcut, Shift+Alt+B by default, is meant to put the
keyboard into the tree so that the arrow keys move between nodes. It called
focus() on the rc-dock tab pane wrapping the tree, and that pane is a plain
div with no tabindex, so it cannot take focus at all: the shortcut selected
a node and left focus wherever it already was, which for anybody navigating
by keyboard means it appeared to do nothing.

Nothing needs a tabindex adding. The tree that react-aspen renders inside
the panel already carries tabindex="-1", so it is focusable
programmatically; the fix is to aim at it, falling back to the panel if the
tree is not there so the behaviour cannot get worse than it was.

Found whilst reviewing pgadmin-org#10254, which made this visible: once the Object
Explorer can be collapsed, a shortcut that silently fails to focus it is
much easier to notice.
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Now that the shortcut actually lands keyboard focus on the tree, the focus
indicator becomes something users see routinely, and left to the browser it is
an outline-style: auto ring drawn in the host's accent colour. In practice that
means it appears orange in one browser and blue in another, and Safari may not
draw it at all, so a keyboard user there gets no indication of where focus has
gone.

Style it with theme.otherVars.activeBorder instead, matching how the dock tabs
already indicate focus, so it is consistent across browsers and themes:
#326690 on light, #d4d4d4 on dark, #fff on high contrast. The -1px outline
offset keeps it inside the scrolling container rather than being clipped at the
edges.

Verified in the browser: with focus on the tree, the computed outline is
"rgb(50, 102, 144) solid 1px" with a -1px offset, in place of the previous
"auto" ring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant