This repository was archived by the owner on Sep 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
packages/devtools-reps/src/object-inspector Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff 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 } ) ;
Original file line number Diff line number Diff 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 ( ) ;
You can’t perform that action at this time.
0 commit comments