onChange + onKeyDown same as react?
I have a component:
The React version shows:
onKeyDown
onChange
When an input is changed.
Solid hover only shows:
onKeyDown and then with a blur, it shows the onChange.
Is the Solid different to React for this, or do I need to use different mechanisms?
See videos.
Thanks!
16 Replies
You would need to use
onInput
Awesome that was it. Thanks!
It doesn't move to the next input. So maybe something else. Going to debug...
@REEEEE would you know a better way of assigning the ref?
The end result should be (see image). But instead I'm getting [null, null, null, null].

Are you passing the ref inside the
Input
-component to the input
element?
Code looks good
Only thing I see is that it will not change the length of the inputsRef-array if local.length
becomes smallerI could be wrong but I think that method of using Array and fill, causes issues
Although in this case it probably shouldn't 🤔
Right?
With the way how it is spread and the index set
Yeah that's what I'm thinking. Could be when/where it's logged?
In the input component:
And in the box component it also gets assigned to the element.
I'm pretty sure it's working as I'm now 80/106 components correctly ported. Although I think I will make a poc to ensure it is.
Shouldn't it be
props.ref
?
Are you destructuring somewhere?It's using a polymorphic factory to get the ref:
Mmm... can you show me how that works?
This is the code: https://raw.githubusercontent.com/paulm17/mantinesolid/refs/heads/main/packages/%40mantine/core/src/core/factory/polymorphic-factory.tsx
As to how it works. Way above my paygrade 😅 I had to use AI to get it over the line.
What problem is this code solving? Mimicking
React.ForwardRef
?
Can you try to do props.ref
instead of ref
? Throughout all the layers?Pretty much yes. For this and the factory.tsx it's assigning both the props and the refs to the component. There is another layer above which coalesces the theme and other data to be available to the component.
Sure, it might be tomorrow now as I have ran out of time. I do appreciate your input. (pardon the pun)
Ye my bet is here is where the problem is. Iirc in react 19 they r gonna get rid of the ForwardRef and do it like solid, so maybe it's worth to already change the abstraction to have it more solid-like.
Ye, ur doing this type-assertion so it all looks good type-wise, but I think there is some proper hallucination going on over here .
I can confirm that refs work just fine actually.
Isolated where it breaks:
export const Input = polymorphicFactory<InputFactory>((_props, ref) => {
ref={ref}
changed to:
ref={(props as any).ref}
now works.
I resolved the issue in the polymorphic factory. Can't match the typings. AI quickly folds 😂
@bigmistqke @REEEEE thanks for the help!