Confused about context.
No poc, as there's too much code. Here's the dir of the component:
https://github.com/paulm17/mantinesolid/tree/main/packages/%40mantine/core/src/component/Checkbox
Here's the component in action:
https://mantine.dev/core/checkbox/#checkboxcard-component It's the one below the text:
https://mantine.dev/core/checkbox/#checkboxcard-component It's the one below the text:
You can use Checkbox.Card with Checkbox.Group the same way as Checkbox component:Here is the context provider: https://github.com/paulm17/mantinesolid/blob/main/packages/%40mantine/core/src/component/Checkbox/CheckboxGroup/CheckboxGroup.tsx#L81 Here is the card onclick event: https://github.com/paulm17/mantinesolid/blob/main/packages/%40mantine/core/src/component/Checkbox/CheckboxCard/CheckboxCard.tsx#L130 All I can get is the onclick event and then nothing. What is annoying 😅 Checkbox Indicator on it's own - Works CheckboxCard and/or CheckboxIndicator - Works CheckboxGroup + CheckboxCard + Checkbox Indicator - Does not work uncontrolled/controlled
60 Replies
This part doesn't make sense to me, why is it a function?

I have no idea. A lot of this boils down to. I simply don't understand solid.
I have tried ctx.onChange(local.value || '') but then saw in corvu that pattern.
I mean that code wouldn't ever run because it's a function that's not called
It is being called. In the console I see:
checkboxcard onClick @mantine/core
checkboxcard onClick @mantine/hooks
checkboxcard onClick @mantine/notifications
sorry I am misunderstanding
The onclick is but the onChange wouldn't
remove
() =>
partI have done and tried again. Nothing different happens.
This is what happens when I launch and then click.

what happens if you log ctx
in which component?
in the onClick
of checkboxcard
so it is getting the context just fine, so the onChange call should be firing
Could it be how you're testing it? Is it a normal local dev or through storybook
This is normal dev. I can't get a storybook to work sadly.
Oh lol
I see
in the checkboxgroup, change
onChange
to onChange: handleChange

It's just swallowing the stuff you pass to it
and not calling the actual function
Nice, so now handleChange is firing. But then dies at setValue 😂 . Let me see if I can take it over here.
Thanks for the help again, appreciate it!
Nice! Just for sanity checking, make sure stuff like this is a function, it could cause issues

do you mean like here for the Box component underneath?
Was doing it again. Shouldn't have looked at that other repo lol 😂
I meant
_checked
should be a function like this:
Just so if the props checked or indeterminate changes, it'll be reactive
for safetySo I am able to get the context + uncontrolled inputs to work.
CheckboxIndicator.tsx:
CheckboxCard.tsx
When an option changes, see all 3 flash. Shouldn't only 1 be flashing?
Found out that the CheckboxGroup is somehow mounting 3 times. 😩
So something upstream is incorrect.
Probably the factory function
Change the part that calls the ui function to be
untrack(() => ui(props, refHandler)
Thanks. Didn't have any effect also I tried to memoize it and no effect either.
It's definitely upstream but only the factory function stuff looks like it would trigger the issue 🤔
Is the withProps subcomppnent of the factory function being used? It could also be causing it if you dont untrack
It's not being used.
It seems to be Box but I can't fix the issue:
The AST
I have trimmed down the component down to:
So only 1 Text should be displayed.
Everything is memoized. 🤦♂️
Well you dont want everything to be memoized
It's not like react memo where it can diff components
It could be the multiple use of props.children in the Box component
I think just doing
{props.children}
should be good enoughI removed all that and started again
With dynamic. I get 3 Text components.
With that function and divs. I get 1 Text component.
Adding children to splitProps and then
resolved the issue 🤦♂️
hah nice
children to splitProps was the key. Without it, I get 3x Text.
I'm actually on the verge of throwing in the towel. Solid makes no sense compared to React.
haha well using React patterns in Solid will do that to you
I'm actually not trying to do that. I'm coming in with zero knowledge and being humble and wanting to honestly debug this. And I get zero feedback. 😄
Also the chrome devtools work when they want to. 😂
That's fair, there's some level of fundamentals to understand about the differences / how Solid operates that makes the migration a bit challenging
I haven't used the devtools in forever
Also I successfully got the CheckboxGroup to work with context and uncontrolled inputs. Then I toggled the main component to use controlled. Guess what, now the CheckboxGroup no longer works 😂
And unable to debug again. The console.logs I had previously don't fire. 🤦♂️
welp
haha
exactly 😂
I would just make sure anything that reads a reactive source (props or a signal) are functions
Now the console.logs are starting to look normal. Before I fixed box. I had 81 checked 😂

@REEEEE thanks so much for the help!
Finally, all working. Controlled/Uncontrolled and With/without context.
The only issue. Is that CheckboxGroup-Controlled with react. Allows you to have Option 1 and 2 both selected at the same time. I'm putting that down to a react thing. Not possible with solid.
Nice! You definitely should be able to have both selected, there shouldn't be anything solid or react specific stopping that from happening
My guess is that this logic is breaking

in checkbox
Here is the react version: https://codesandbox.io/p/sandbox/mantine-react-template-q4dd5d
It's empty
https://codesandbox.io/p/devbox/mantine-react-template-forked-wx965g?workspaceId=ws_66SZtu7eK3Fdhpmgo4DbQv
Checkbox isn't used for these components. It's either UnstyledButton or Box.
Need an account :P
I give up then. 😅
Could you show me the code for that demo?
It's the same as this.
Here's a short video for react
huh that's really weird behaviour
because the logic says that it's setting the state to either 1 or 2 when you click
but for some reason both are being selected?
Like if you wanted the same behaviour in solid, it would be more like this
Yeah, I came to the very same conclusion.
so idk if that's a react bug, mantine bug, or I'm not understanding something with the components
For right now, I'm chalking it down to a react bug. Nothing really jumps out when I review the code. But I might ask Vitaly when I have completed the poc. Now I have a really complex component under my belt. I think I can do the rest of them.
22 / 84 done so far
Nice, looking forward to seeing it complete
@REEEEE just to confirm. Should I be seeing reactive for all 3 when I toggle 1?
Is this a case where I should be using Index?
technically yeah
but I can't confirm because I'm not sure what the devtools record
Just to clarify my thinking/explain why you see all 3 reacting, it's because it's a signal and every time you set the value you're setting a new array and all the signals that do the "includes(myValue)" thing are triggered.
Thanks! It's a parent component rather than the individual ones. So I can change it easily. I'll do so and then see what the difference is.