File tree Expand file tree Collapse file tree 2 files changed +50
-39
lines changed Expand file tree Collapse file tree 2 files changed +50
-39
lines changed Original file line number Diff line number Diff line change @@ -605,38 +605,44 @@ storiesOf("Annotator", module)
605605 return (
606606 < HotKeys keyMap = { defaultKeyMap } >
607607 < 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 >
640646 </ div >
641647 </ HotKeys >
642648 )
Original file line number Diff line number Diff line change 11// @flow
22
3- import React , { useState , useRef } from "react"
3+ import React , { useState , useRef , useCallback } from "react"
44import type { Node } from "react"
55import Grid from "@material-ui/core/Grid"
66import { makeStyles } from "@material-ui/core/styles"
@@ -81,6 +81,15 @@ export default ({
8181
8282 let impliedVideoRegions = useImpliedVideoRegions ( state )
8383
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+
8493 return (
8594 < Fullscreen
8695 enabled = { state . fullScreen }
@@ -93,12 +102,8 @@ export default ({
93102 < HotkeyDiv
94103 tabIndex = { - 1 }
95104 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 }
102107 allowChanges
103108 handlers = { hotkeyHandlers }
104109 className = { classnames (
You can’t perform that action at this time.
0 commit comments