Norigin-Spatial-Navigation icon indicating copy to clipboard operation
Norigin-Spatial-Navigation copied to clipboard

allow to specify the type of `ref` returned by `useFocusable`

Open zemlanin opened this issue 5 months ago • 4 comments

  • Originally, I've tried E extends HTMLElement = HTMLElement, but that made the new type arg effectively required because of Type 'RefObject<HTMLElement>' is not assignable to type 'Ref<HTMLDivElement>'.
  • src/App.tsx should passes type check without changes in this PR, but adding the new type arg seemed like a correct thing to do in the example

zemlanin avatar Nov 14 '25 12:11 zemlanin

Hi, thank you for the PR. I’m wondering whether this change is actually necessary or if it’s solving a real issue. My main concern with the proposed approach is that it doesn’t support react-native, where HTMLElements aren’t available at all.

xavi160 avatar Dec 10 '25 09:12 xavi160

I’m wondering whether this change is actually necessary or if it’s solving a real issue.

We’re trying to eliminate as much any from our code base as possible, and using a type arg seems like a clean way of doing that from the caller side

My main concern with the proposed approach is that it doesn’t support react-native, where HTMLElements aren’t available at all.

Riiight. Removing extends HTMLElement would solve that concern, wouldn’t it?

(I don’t know if there’s an another approach of typing things like that in a way that would work in both react-dom and react-native)

zemlanin avatar Dec 10 '25 09:12 zemlanin

Riiight. Removing extends HTMLElement would solve that concern, wouldn’t it?

Yep. Just adding the generic type and defaulting it to any should do the trick for you

xavi160 avatar Dec 10 '25 11:12 xavi160

Yep. Just adding the generic type and defaulting it to any should do the trick for you

https://github.com/NoriginMedia/Norigin-Spatial-Navigation/pull/188/commits/32bc04f01592c46c354cd13a305a3b2321265198 + https://github.com/NoriginMedia/Norigin-Spatial-Navigation/pull/188/commits/9dcbf2615286acaaaaa826d0a5eb3a7487732422

zemlanin avatar Dec 10 '25 13:12 zemlanin

@xavi160 @predikament Could you look at this once more? 🙏

zemlanin avatar Jan 07 '26 11:01 zemlanin

Bump?..

Could somebody with permissions merge this and publish a new version?

zemlanin avatar Feb 04 '26 14:02 zemlanin