Skip to content

Commit 9b1942e

Browse files
committed
docs: updated readme examples
- corrected main example markup - add transition example
1 parent ac34fdb commit 9b1942e

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

README.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ A renderless version provides all the functionality required to build a proper `
6262
```html
6363
<!-- compose into you own markup, MyDialog.vue -->
6464
<template>
65-
<a11y-vue-dialog-renderless
66-
v-bind="$props"
67-
@close="$emit('close')"
68-
#default="{ open, closeFn, backdropRef, dialogRef, titleRef, closeRef, focusRef }"
69-
>
70-
<portal to="a11y-vue-dialogs" v-if="open">
65+
<portal to="a11y-vue-dialogs" v-if="open">
66+
<a11y-vue-dialog-renderless
67+
v-bind="$props"
68+
v-bind="$listeners"
69+
#default="{ open, closeFn, backdropRef, dialogRef, titleRef, closeRef, focusRef }"
70+
>
7171
<div class="youclasses"
7272
v-bind="backdropRef.props"
7373
v-on="backdropRef.listeners"
@@ -99,8 +99,8 @@ A renderless version provides all the functionality required to build a proper `
9999
</footer>
100100
</div>
101101
</div>
102-
</portal>
103-
</a11y-vue-dialog-renderless>
102+
</a11y-vue-dialog-renderless>
103+
</portal>
104104
</template>
105105

106106
<script>
@@ -141,6 +141,34 @@ export default {
141141
- Here's a [codesandbox to play with](https://codesandbox.io/s/renderless-a11y-vue-dialog-q5lqk?file=/src/components/DialogConfirm.vue)
142142
- Checkout [this example](https://github.com/edenspiekermann/a11y-dialog#expected-dom-structure) for what's the minimum expected markup for an accessible dialog
143143

144+
145+
### Usage with <transition>
146+
> When you use a <transition> as the root element of the portal and then remove the portal (i.e. with v-if) or set its disabled prop to true, no leave transition will happen.
147+
> While this is to expected, as the same thing would happen if you removed a div that contains a <transition>, it often trips people up, which is why it's mentioned here.
148+
> [vue-simple-portal](https://github.com/LinusBorg/vue-simple-portal#transitions)
149+
150+
_if you really need to apply the `v-if` to portal, check the example in the link above_
151+
152+
But based on the info above, this also works fine:
153+
154+
```html
155+
<portal to="a11y-vue-dialogs">
156+
<!--
157+
[1] note the v-if is applied to transition not portal.
158+
could also be applied to the component itself
159+
-->
160+
<transition name="fade" appear v-if="open">
161+
<a11y-vue-dialog-renderless
162+
v-bind="$props"
163+
v-bind="$listeners"
164+
#default="{ open, closeFn, backdropRef, dialogRef, titleRef, closeRef, focusRef }"
165+
>
166+
<!-- your implementation -->
167+
</a11y-vue-dialog-renderless>
168+
</transition>
169+
</portal>
170+
```
171+
144172
## Play
145173

146174
A playground is used to test the component locally. It uses [`vue/cli` instant prototyping feature](https://cli.vuejs.org/guide/prototyping.html), so the downside is that you have to install it globally.

docs/guide/renderless-usage.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Each `ref` suffixed slotProp is an object that contains a "props" and "listeners
2121
```html
2222
<template>
2323
<!-- compose into you own markup, MyDialog.vue -->
24-
<a11y-vue-dialog-renderless
25-
v-bind="$props"
26-
@close="$emit('close')"
27-
#default="{ open, closeFn, backdropRef, dialogRef, titleRef, closeRef, focusRef }"
28-
>
29-
<portal to="a11y-vue-dialogs" v-if="open">
24+
<portal to="a11y-vue-dialogs" v-if="open">
25+
<a11y-vue-dialog-renderless
26+
v-bind="$props"
27+
v-bind="$listeners"
28+
#default="{ open, closeFn, backdropRef, dialogRef, titleRef, closeRef, focusRef }"
29+
>
3030
<div class="youclasses"
3131
v-bind="backdropRef.props"
3232
v-on="backdropRef.listeners"
@@ -58,8 +58,8 @@ Each `ref` suffixed slotProp is an object that contains a "props" and "listeners
5858
</footer>
5959
</div>
6060
</div>
61-
</portal>
62-
</a11y-vue-dialog-renderless>
61+
</a11y-vue-dialog-renderless>
62+
</portal>
6363
</template>
6464

6565
<script>

0 commit comments

Comments
 (0)