feat(modal): make default slot a scoped slot #3095
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Pull Request:
This is a minor but useful change to make the default slot (modal body) into a scoped slot. As per the blog post for the Vue 2.6 release, in the future all slots will be scoped slots anyway:
In this PR the only scoped prop that I exposed was
visible
, which is whether the modal is visible or not. This is very useful because it makes it so you can easily mount/unmount modal content on visibility. This removes the need to worry about reseting components when a modal is opened again, which can be annoying when composing the content of components, some of which may not have an easy way to reset their state. From the blog post, there's also a small performance improvement using scoped slots, so that comes along for free as well.Example of how this works with the scoped slot:
This ensures
MyComponent
is unmounted and mounted any time the modal is shown, resulting in fresh state, which is my desired outcome.PR checklist:
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact:
The PR fulfills these requirements:
dev
branch, not themaster
branchfixes #xxxx[,#xxxx]
, where "xxxx" is the issue number)and adding a new feature, break them into separate PRs if at all possible.
Conventional Commits naming convention (i.e.
"fix(alert): not alerting during SSR render", "docs(badge): Updated pill examples, fix typos",
"chore: fix typo in docs", etc). This is very important, as the
CHANGELOG
is generatedfrom these messages.
If new features/enhancement/fixes are added or changed:
package.json
for slot andevent changes)
keyboard only users? clickable items should be in the tab index, etc)
If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes:
suggestion issue first and wait for approval before working on it)