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
Class passed to component is lost in the portal #101
Comments
You are missing that the class that you define on the component will be added to its root element - which is the portal, not the div inside it. However, you can set <div class="dialog-mask" v-bind="$attrs"> Please see the Vue documentation for those two properties of you want to learn more. |
The Vue documentation states:
Any other solution? Edit: Seeing this issue, I ended up using a custom prop after all: |
Oh, right, forgot about that limitation. I will add this to the caveats section in the docs later. |
If the dialog has a single root element, wouldn't the |
Just realized that slim is only applicable to I also tried setting portal's tag to |
This. There's really no way to make this work. |
It feels hacky but i solved this using <template>
<portal to="root">
<div :class="$vnode.data.staticClass" />
</portal>
</template> This way class (and potentially any data inside vnode) can be pass down through the portal |
I use portal-vue in order to move all my modals at the top level for z-ordering. My dialog component setup is like so:
When I try to use the component, I often do something like:
However, when the
<div>
is rendered in theportal-target
, it only has thedialog-mask
class, notdialog-mask myDialogClass
.I'm struggling to get the class property to bind. I could use a custom dialogClass prop and do it manually, but I'd rather use vue's built-in clear syntax.
Am I missing something?
The text was updated successfully, but these errors were encountered: