-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[listbox] dynamic add or remove options #1070
Comments
It's working if you use <lion-listbox>
<lion-options slot="input">
${this.options.map(
(option) =>
html`
<lion-option .choiceValue=${option}>${option}</lion-option>
`
)}
</lion-options>
</lion-listbox> |
Yeah, I noticed as well that this api doesn't support all edge cases. It's sugar on top of wrapping it in lion-options. It moves the nodes it find in the regular slot over to there ('there' is Since the individual lion-options are moved,
This is solvable by a hack (for instance by setting So the 'sugared api' works when options are declared declaratively or via a loop wich content is never updated. Unless someone sees another posible fix of course |
Update on this: the lit repeat directive might solve this issue. You will run into other problems then, since FormRegistrarMixin assumes the order of registration corresponds with dom order (or, more precisely, parts of the code expect .formElements order to correspond with dom order). When we make sure inside FormRegistrarMixin that dom order is guarantueed inside formElements, the issue might be solved. We should keep in mind that (since many elements register synchronously), we do the dom reordering async/batched for perf. |
@MathieuPuech This should work now thanks to a fix in the FormRegistrarMixin by @daKmoR 💪 ${repeat(
this.options,
option => option.id,
option => html`
<lion-option
.choiceValue=${option.value}
></lion-option>
`,
)} Closing this one, feel free to reopen when needed... |
does it means that dynamic options can only be done with lit? |
Until we have the AOM, yes. |
what do you mean by that? 🤔 the lit directive |
Oh ok, so it’s an issue with Lit html rendering which is too much reusing the nodes. It may not happen with other rendering engines if that’s the case. I will see if there is any issues with other engine and reopen the issue if needed. Thanks for the clarification |
Expected behavior
When using listbox and adding/removing options, it fail removing the option
Actual Behavior
https://webcomponents.dev/edit/Qii8XlpIwKaK5Am3FnYC
Additional context
@lion/listbox
0.3.1The text was updated successfully, but these errors were encountered: