File tree 2 files changed +50
-39
lines changed
2 files changed +50
-39
lines changed Original file line number Diff line number Diff line change @@ -605,38 +605,44 @@ storiesOf("Annotator", module)
605
605
return (
606
606
< HotKeys keyMap = { defaultKeyMap } >
607
607
< div >
608
- < Annotator
609
- onExit = { actionAddon ( "onExit" ) }
610
- middlewares = { [
611
- ( store ) => ( next ) => ( action ) => {
612
- actionAddon ( action . type ) ( action )
613
- return next ( action )
614
- } ,
615
- ] }
616
- images = { [
617
- {
618
- src : exampleImage ,
619
- name : "Seve's Desk" ,
620
- regions : testRegions ,
621
- } ,
622
- ] }
623
- />
624
- < Annotator
625
- onExit = { actionAddon ( "onExit" ) }
626
- middlewares = { [
627
- ( store ) => ( next ) => ( action ) => {
628
- actionAddon ( action . type ) ( action )
629
- return next ( action )
630
- } ,
631
- ] }
632
- images = { [
633
- {
634
- src : exampleImage ,
635
- name : "Seve's Desk" ,
636
- regions : testRegions ,
637
- } ,
638
- ] }
639
- />
608
+ < div style = { { height : 600 } } >
609
+ < Annotator
610
+ onExit = { actionAddon ( "onExit" ) }
611
+ regionClsList = { [ "Alpha" , "Beta" , "Charlie" , "Delta" ] }
612
+ imageClsList = { [ "Alpha" , "Beta" , "Charlie" , "Delta" ] }
613
+ middlewares = { [
614
+ ( store ) => ( next ) => ( action ) => {
615
+ actionAddon ( action . type ) ( action )
616
+ return next ( action )
617
+ } ,
618
+ ] }
619
+ images = { [
620
+ {
621
+ src : exampleImage ,
622
+ name : "Seve's Desk" ,
623
+ regions : testRegions ,
624
+ } ,
625
+ ] }
626
+ />
627
+ </ div >
628
+ < div style = { { height : 600 } } >
629
+ < Annotator
630
+ onExit = { actionAddon ( "onExit" ) }
631
+ middlewares = { [
632
+ ( store ) => ( next ) => ( action ) => {
633
+ actionAddon ( action . type ) ( action )
634
+ return next ( action )
635
+ } ,
636
+ ] }
637
+ images = { [
638
+ {
639
+ src : exampleImage ,
640
+ name : "Seve's Desk" ,
641
+ regions : testRegions ,
642
+ } ,
643
+ ] }
644
+ />
645
+ </ div >
640
646
</ div >
641
647
</ HotKeys >
642
648
)
Original file line number Diff line number Diff line change 1
1
// @flow
2
2
3
- import React , { useState , useRef } from "react"
3
+ import React , { useState , useRef , useCallback } from "react"
4
4
import type { Node } from "react"
5
5
import Grid from "@material-ui/core/Grid"
6
6
import { makeStyles } from "@material-ui/core/styles"
@@ -81,6 +81,15 @@ export default ({
81
81
82
82
let impliedVideoRegions = useImpliedVideoRegions ( state )
83
83
84
+ const refocusOnMouseEvent = useCallback ( ( e ) => {
85
+ if ( ! innerContainerRef . current ) return
86
+ if ( innerContainerRef . current . contains ( document . activeElement ) ) return
87
+ if ( innerContainerRef . current . contains ( e . target ) ) {
88
+ innerContainerRef . current . focus ( )
89
+ e . target . focus ( )
90
+ }
91
+ } , [ ] )
92
+
84
93
return (
85
94
< Fullscreen
86
95
enabled = { state . fullScreen }
@@ -93,12 +102,8 @@ export default ({
93
102
< HotkeyDiv
94
103
tabIndex = { - 1 }
95
104
divRef = { innerContainerRef }
96
- onMouseDown = { ( e ) => {
97
- if ( innerContainerRef . current ) innerContainerRef . current . focus ( )
98
- } }
99
- onMouseOver = { ( e ) => {
100
- if ( innerContainerRef . current ) innerContainerRef . current . focus ( )
101
- } }
105
+ onMouseDown = { refocusOnMouseEvent }
106
+ onMouseOver = { refocusOnMouseEvent }
102
107
allowChanges
103
108
handlers = { hotkeyHandlers }
104
109
className = { classnames (
You can’t perform that action at this time.
0 commit comments