You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here the Select has the default value selected to "a" so it should display the content of the Option with value "a".
As we cannot access the DOM in the server, I wanted to access the elements in the Slot and find the one with the value.
Unfortunately, this is possible with children, but not with Slot.
Describe the solution you'd like
Access a Readonly list of the JSXNode like you would do with children. Maybe something like that :
exportconstSelect=component$(({ value, placeholder }: SelectProps)=>{constslots=useSlot();// snapshot of the elements in the SlotconstinitialContent=slots.default.find((option)=>option.props.value===value)??'';constdisplayContent=useSignal(initialContent);return<><button>{displayContent.value??placeholder}</button><dialog><Slot/>{/* Options here */}</dialog></>});
Is your feature request related to a problem?
I've got a
Select
element and I want to display the content of the selected option :Here the
Select
has the default value selected to "a" so it should display the content of the Option with value "a".As we cannot access the DOM in the server, I wanted to access the elements in the Slot and find the one with the value.
Unfortunately, this is possible with children, but not with Slot.
Describe the solution you'd like
Access a Readonly list of the JSXNode like you would do with
children
. Maybe something like that :Describe alternatives you've considered
Use inline component and children.
Or use DOM manipulation in the server if it becomes possible.
Additional context
No response
The text was updated successfully, but these errors were encountered: