Skip to content

Commit a30d203

Browse files
darkwingjasonLaster
authored andcommitted
[SourceTree] Don't blur when tree is no longer focused (firefox-devtools#6488)
1 parent 0effda7 commit a30d203

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/devtools-components/src/tree.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ class Tree extends Component {
341341
// Additional classes to add to the root element.
342342
className: PropTypes.string,
343343
// style object to be applied to the root element.
344-
style: PropTypes.object
344+
style: PropTypes.object,
345+
// Prevents blur when Tree loses focus
346+
preventBlur: PropTypes.bool
345347
};
346348
}
347349

@@ -606,7 +608,9 @@ class Tree extends Component {
606608
* Sets the state to have no focused item.
607609
*/
608610
_onBlur() {
609-
this._focus(undefined);
611+
if (!this.props.preventBlur) {
612+
this._focus(undefined);
613+
}
610614
}
611615

612616
/**

src/components/PrimaryPanes/SourcesTree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ class SourcesTree extends Component<Props, State> {
401401
onCollapse: this.onCollapse,
402402
onExpand: this.onExpand,
403403
onFocus: this.focusItem,
404-
renderItem: this.renderItem
404+
renderItem: this.renderItem,
405+
preventBlur: true
405406
};
406407

407408
return <ManagedTree {...treeProps} />;

src/components/test/__snapshots__/SourcesTree.spec.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ exports[`SourcesTree After changing expanded nodes Shows the tree with four.js,
2929
onCollapse={[Function]}
3030
onExpand={[Function]}
3131
onFocus={[Function]}
32+
preventBlur={true}
3233
renderItem={[Function]}
3334
/>
3435
</div>
@@ -57,6 +58,7 @@ exports[`SourcesTree Should show the tree with nothing expanded 1`] = `
5758
onCollapse={[Function]}
5859
onExpand={[Function]}
5960
onFocus={[Function]}
61+
preventBlur={true}
6062
renderItem={[Function]}
6163
/>
6264
</div>
@@ -92,6 +94,7 @@ exports[`SourcesTree When loading initial source Shows the tree with one.js, two
9294
onCollapse={[Function]}
9395
onExpand={[Function]}
9496
onFocus={[Function]}
97+
preventBlur={true}
9598
renderItem={[Function]}
9699
/>
97100
</div>
@@ -184,6 +187,7 @@ exports[`SourcesTree on receiving new props updates highlighted items updates hi
184187
onCollapse={[Function]}
185188
onExpand={[Function]}
186189
onFocus={[Function]}
190+
preventBlur={true}
187191
renderItem={[Function]}
188192
/>
189193
</div>
@@ -286,6 +290,7 @@ exports[`SourcesTree on receiving new props updates list items updates list item
286290
onCollapse={[Function]}
287291
onExpand={[Function]}
288292
onFocus={[Function]}
293+
preventBlur={true}
289294
renderItem={[Function]}
290295
/>
291296
</div>
@@ -640,6 +645,7 @@ exports[`SourcesTree with custom root renders custom root source list 1`] = `
640645
onCollapse={[Function]}
641646
onExpand={[Function]}
642647
onFocus={[Function]}
648+
preventBlur={true}
643649
renderItem={[Function]}
644650
/>
645651
</div>

0 commit comments

Comments
 (0)