Skip to content

Add transition as root to the migration guide #1067

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

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const sidebar = {
'/guide/migration/slots-unification',
'/guide/migration/suspense',
'/guide/migration/transition',
'/guide/migration/transition-as-root',
'/guide/migration/transition-group',
'/guide/migration/v-on-native-modifier-removed',
'/guide/migration/v-model',
Expand Down
61 changes: 61 additions & 0 deletions src/guide/migration/transition-as-root.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
badges:
- breaking
---

# Transition as Root <MigrationBadges :badges="$frontmatter.badges" />

## Overview

Using a `<transition>` as a component's root will no longer trigger transitions when the component is toggled from the outside.

## 2.x Behavior

In Vue 2, it was possible to trigger a transition from outside a component by using a `<transition>` as the component's root:

```html
<!-- modal component -->
<template>
<transition>
<div class="modal"><slot/></div>
</transition>
</template>
```

```html
<!-- usage -->
<modal v-if="showModal">hello</modal>
```

Toggling the value of `showModal` would trigger a transition inside the modal component.

This worked by accident, not by design. A `<transition>` is supposed to be triggered by changes to its children, not by toggling the `<transition>` itself.

This quirk has now been removed.

## Migration Strategy

A similar effect can be achieved by passing a prop to the component instead:

```vue
<template>
<transition>
<div v-if="show" class="modal"><slot/></div>
</transition>
</template>
<script>
export default {
props: ['show']
}
</script>
```

```html
<!-- usage -->
<modal :show="showModal">hello</modal>
```

## See also

- [Some transition classes got a rename](/guide/migration/transition.html)
- [`<TransitionGroup>` now renders no wrapper element by default](/guide/migration/transition-group.html)
1 change: 1 addition & 0 deletions src/guide/migration/transition-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ In Vue 3, we have [fragment support](/guide/migration/fragments.html), so compon
## See also

- [Some transition classes got a rename](/guide/migration/transition.html)
- [`<Transition>` as a root can no longer be toggled from the outside](/guide/migration/transition-as-root.html)
1 change: 1 addition & 0 deletions src/guide/migration/transition.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ The `<transition>` component's related prop names are also changed:

## See also

- [`<Transition>` as a root can no longer be toggled from the outside](/guide/migration/transition-as-root.html)
- [`<TransitionGroup>` now renders no wrapper element by default](/guide/migration/transition-group.html)