kobaltedev / kobalte

A UI toolkit for building accessible web apps and design systems with SolidJS.
https://kobalte.dev
MIT License
1.23k stars 63 forks source link

TextField display [object Event] #459

Closed kapilpipaliya closed 1 month ago

kapilpipaliya commented 1 month ago

Describe the bug When <TextField.Input onChange={setValue}/> is passed TextInput displays [object Event] inside it.

function ControlledExample() {
    const [value, setValue] = createSignal();
    return (
        <>
            <TextField value={value()} onChange={setValue}>
                <TextField.Input onChange={setValue}/>
            </TextField>
            <p>Your favorite fruit is: {value()}.</p>
        </>
    );
}

Expected behavior It should ignore passed onChange and display proper value.

Screenshots

image
kapilpipaliya commented 1 month ago

TextFieldContext should be exported. so we can overwrite TextFieldInput component if required.

jer3m01 commented 1 month ago

setValue should only be called from the onChange of TextField and not TextField.Input.

The root onChange recieves a value with kobalte handling whereas the one from the input is the native event and should only be used for advanced custom handling.

kapilpipaliya commented 1 week ago

Can we export all context for example TextFieldContext ?

jer3m01 commented 1 week ago

Can we export all context for example TextFieldContext ?

That's planned #321, will need time to design the API, no ETA.