Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 9fd97da

Browse files
committed
Don't pass onFocus prop if disabledFocus is true
1 parent bb31728 commit 9fd97da

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/devtools-reps/src/object-inspector/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ class ObjectInspector extends Component {
504504

505505
onExpand: item => this.setExpanded(item, true),
506506
onCollapse: item => this.setExpanded(item, false),
507-
onFocus: this.focusItem,
507+
onFocus: disabledFocus ? null : this.focusItem,
508508

509509
renderItem: this.renderTreeItem
510510
});

packages/devtools-reps/src/object-inspector/tests/component/events.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ describe("ObjectInspector - properties", () => {
4141
expect(onFocus.mock.calls.length).toBe(1);
4242
});
4343

44+
it("does not call the onFocus when given focus but disabledFocus is true", () => {
45+
const stub = gripRepStubs.get("testMaxProps");
46+
const onFocus = jest.fn();
47+
48+
const oi = mount(ObjectInspector(generateDefaults({
49+
disabledFocus: true,
50+
roots: [{
51+
path: "root",
52+
contents: {
53+
value: stub
54+
}
55+
}],
56+
onFocus,
57+
})));
58+
59+
const node = oi.find(".node").first();
60+
node.simulate("focus");
61+
62+
expect(onFocus.mock.calls.length).toBe(0);
63+
});
64+
4465
it("calls the onDoubleClick prop function when provided one and double clicked", () => {
4566
const stub = gripRepStubs.get("testMaxProps");
4667
const onDoubleClick = jest.fn();

0 commit comments

Comments
 (0)