-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Passing component to grandchildren's nested named slot will resolve in the default slot. #6996
Labels
Comments
WOW that's amazing! |
btw this is already out in 2.5.3 :) |
Does this also work with slot-scope in 2.5.3? :) |
lovelope
pushed a commit
to lovelope/vue
that referenced
this issue
Feb 1, 2018
@faragos here's how I accomplished passing slots to a grandchild that uses slot-scope. |
@alex-martinez thanks for posting your solution, it was a big help :) |
f2009
pushed a commit
to f2009/vue
that referenced
this issue
Jan 25, 2019
aJean
pushed a commit
to aJean/vue
that referenced
this issue
Aug 19, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
2.5.2
Reproduction link
https://jsfiddle.net/daxchen/k75y6tu0/
Steps to reproduce
My use case is that I have a default layout with Toolbar and main content wrapper. But some pages needs a
SearchBar
and some don't, and layouts may have different levels.So I created a component called
LayoutDefault
as a base for other layouts to use. And because I want to be able to replace the default Toolbar when needed, I put the default Toolbar in<slot name="toolbar">
, withToolbar
as fallback content.Code snippet:
I make these kind of components because I want to be able to:
"toolbarSlot"
in above example)And then in other layout components, I do this:
As you can see, to pass components to grandchild's slots, I used this pattern:
<slot name="foo" slot="foo">
.For some reason, components passed using this pattern will be passed to the default slot if there's one.
See examples 2, 3, and 4 in the reproduction.
What is expected?
I expect when no nothing is passed to a named slot, the fallback content will be rendered, with it's slots too.
What is actually happening?
In example 2, the replaced
Toolbar
is rendered inLayoutDefault
's default slot.In example 3 and 4,
SearchBar
is passed toslot="toolbarSlot"
, but not rendered.Is this the expected behavior?
Or if there's a way for me to make these kind of reusable layouts with each default parts replaceable, and if using the default parts, be able to pass components into their (default parts) slots?
The text was updated successfully, but these errors were encountered: