Open cyan-2048 opened 10 months ago
Thanks for the idea @cyan-2048, we'll have a look as soon as we can!
Sorry for not getting back to you on this, we've had our hands full.
I will do my best to make sure the team looks into this one way or another, as it's a valid suggestion.
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
It's a problem because that would mean I have to figure out myself which element would be focused next (this isn't a problem with https://github.com/luke-chang/js-spatial-navigation, where there's plenty of spatial navigation events present)
Describe the solution you'd like A clear and concise description of what you want to happen.
Just want a way to know what DOM Node or even React Component is about to take the focus
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
in the useFocusable hook, add a custom property that can be passed any object as an argument for onArrowPress
Additional context Add any other context or screenshots about the feature request here.
events fired by luke-chang/js-spatial-navigation that I really miss
sn:willunfocus
true
true
<HTMLElement>
(Navigation Only)<String>
(Navigation Only)'left'
,'right'
,'up'
or'down'
(Navigation Only)<Boolean>
Fired when an element is about to lose the focus.
nextElement
andnextSectionId
indicate where the focus will be moved next.direction
is similar tosn:willmove
but will be omitted here if this move is not caused by direction-related actions (e.g. by@
syntax orfocus()
directly).native
indicates whether this event is triggered by native focus-related events or not.Note: If it is caused by native
blur
event, SpatialNavigation will try to focus back to the original element when you cancel it (but not guaranteed).sn:willfocus
true
true
<String>
<HTMLElement>
(Navigation Only)'left'
,'right'
,'up'
or'down'
(Navigation Only)<Boolean>
Fired when an element is about to get the focus.
sectionId
indicates the currently focused section.previousElement
indicates the last focused element before this move.direction
andnative
are the same assn:willunfocus
.Note: If it is caused by native
focus
event, SpatialNavigation will try to blur it immediately when you cancel it (but not guaranteed).