You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm trying to focus on first button with value "btn 1" using setFocus but its not working as expected. but when i use focusSelf its working fine. Is there anything missing in this code.
In your examples you are passing a prop named focusKey to your focusable component, but you never pass this value to the useFocusable hook itself - Without this the hook cannot know what you want your focus key value to be, so it automatically generates one.
Basically you are missing this important part that I've commented next to in this example:
constCoolButton=({focusKey})=>{const{focused, ref}=useFocusable({focusKey: 'MY_BUTTONS_FOCUS_KEY'// <-- Add this, hardcode a value to check, or use your focusKey prop!});return<buttonref={ref}style={{background: focused ? '#f0f' : '#0f0'}}>I'm a button!</>;
};
Now that you've done this the hook will know of this focus key and doing this will work as you expect:
Describe the bug
I'm trying to focus on first button with value "btn 1" using setFocus but its not working as expected. but when i use focusSelf its working fine. Is there anything missing in this code.
To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: