Skip to content

Commit e4052d4

Browse files
authored
Roll back Tree component onFocus change. (firefox-devtools#6884)
The check that was made there prevented the first item of the Tree to be selected if the click happened inside it. Without this check, the first item is automatically selected and scrolled to, which is causing some weirdness in the console (probably in the debugger as well). The fix was made in mozilla-central directly in the reps bundle as well.
1 parent 6ce2200 commit e4052d4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • packages/devtools-components/src

packages/devtools-components/src/tree.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,17 @@ class Tree extends Component {
817817
if (focused || !nativeEvent || !this.treeRef) {
818818
return;
819819
}
820-
this._focus(traversal[0].item);
820+
821+
const { explicitOriginalTarget } = nativeEvent;
822+
// Only set default focus to the first tree node if the focus came
823+
// from outside the tree (e.g. by tabbing to the tree from other
824+
// external elements).
825+
if (
826+
explicitOriginalTarget !== this.treeRef &&
827+
!this.treeRef.contains(explicitOriginalTarget)
828+
) {
829+
this._focus(traversal[0].item);
830+
}
821831
},
822832
onBlur: this._onBlur,
823833
"aria-label": this.props.label,

0 commit comments

Comments
 (0)