File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
packages/atri-app-core/src Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,7 @@ export function createCanvasMachine(id: string) {
401401 callSubscribers ( "focusEnd" , context , event ) ;
402402 console . log ( "Exited Selected focused State" , id ) ;
403403 } ,
404+
404405 on : {
405406 [ BLUR ] : {
406407 target : unfocused ,
Original file line number Diff line number Diff line change 11import { DecoratorData } from "../../types" ;
22import { componentStoreApi } from "../../api/componentStoreApi" ;
3- import { useEffect } from "react" ;
3+ import { useEffect , useState } from "react" ;
4+ import { subscribeCanvasMachine } from "../../api" ;
45
56export function useFocusComponent ( props : DecoratorData ) {
7+ const [ id , setId ] = useState ( "" ) ;
8+
9+ useEffect ( ( ) => {
10+ console . log ( "State useFocusComponent" ) ;
11+ const setFocus = subscribeCanvasMachine ( "focus" , ( context ) => {
12+ setId ( context . selected || "" ) ;
13+ } ) ;
14+ return ( ) => {
15+ setFocus ( ) ;
16+ } ;
17+ } , [ id ] ) ;
18+
619 useEffect ( ( ) => {
7- const ref = componentStoreApi . getComponentRef ( props . id ) ;
8- if ( ref . current ) {
9- ref . current . tabIndex = 0 ;
10- ref . current . focus ( ) ;
20+ if ( props . id === id ) {
21+ const ref = componentStoreApi . getComponentRef ( props . id ) ;
22+ if ( ref . current ) {
23+ ref . current . tabIndex = 0 ;
24+ ref . current . focus ( ) ;
25+ console . log ( "Running ENter" ) ;
26+ }
1127 }
12- } , [ props . id ] ) ;
28+ } , [ props . id , id ] ) ;
1329}
You can’t perform that action at this time.
0 commit comments