Replies: 3 comments 2 replies
-
we actually had this sort of api before... 🙈 it's a different set of worms - ultimately doing it as we do now is easier to reason and to maintain... that's why we changed it. For the "dynamic" loading what you probably could do is to load the actual definition of the custom element later... html`
<lion-dialog
@opened-changed=${(e) => {
import(new URL('./dialog-content.js', import.meta.url));
}}
>
<lion-button slot="invoker">Show dialog</lion-button>
<div slot="content">
<dialog-content></dialog-content>
</div>
</lion-dialog>
`; or what you did with the dynamic rendering... I think both are valid solutions... maybe we should add it to the docs? |
Beta Was this translation helpful? Give feedback.
-
The thing with dynamic loading is that it doesn't "reset" the element when the dialog is closed. My Even when the content is not a custom element, it can be relevant. For example when opening a login form in a dialog, which is not an unusual pattern. You would want the input fields to be reset (or better yet removed completely) when the dialog is closed, for security reasons. If we don't want render functions, maybe we can use TemplateElement? html`
<lion-dialog>
<lion-button slot="invoker">Show dialog</lion-button>
<template when-opened slot="content">
<dialog-content></dialog-content>
</template>
</lion-dialog>
`; |
Beta Was this translation helpful? Give feedback.
-
Ok. Then we just need a documentation change that explains this workaround. I also think it's useful to put a warning to users that indicates that the dialog content is immediately rendered with display=none. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a feature in my application that I want to show in a dialog (like a login feature). I don't want the feature to load (the DOM elements to be rendered) until the dialog is actually opened. I figured out this workaround to achieve what I want:
I think this type of behaviour is most likely what most users want (the dialog content is not loaded until dialog is opened), but the way to do this is not very clear. Maybe we can change the API somehow to make this easier.
Possibly something like this:
Beta Was this translation helpful? Give feedback.
All reactions