feat(components): [dialog] append dialog to any element (#14317)

* feat(components): [dialog] append dialog to any element

Add the ability to append dialog not just to body, but to any element

* fix(components): [dialog] fix appending to body when append-to is used

* docs(components): [dialog] add version to docs append-to attribute
This commit is contained in:
Karolis_Stoncius_Sneakybox 2023-11-14 13:43:05 +02:00 committed by GitHub
parent 9d65c0be90
commit 02090482ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -125,6 +125,7 @@ When using `modal` = false, please make sure that `append-to-body` was set to **
| modal | whether a mask is displayed | ^[boolean] | true |
| modal-class | custom class names for mask | ^[string] | — |
| append-to-body | whether to append Dialog itself to body. A nested Dialog should have this attribute set to `true` | ^[boolean] | false |
| append-to ^(2.4.3) | which element the Dialog appends to. Will override `append-to-body` | ^[string] | body |
| lock-scroll | whether scroll of body is disabled while Dialog is displayed | ^[boolean] | true |
| custom-class ^(deprecated) | custom class names for Dialog | ^[string] | '' |
| open-delay | the Time(milliseconds) before open | ^[number] | 0 |

View File

@ -13,6 +13,13 @@ export const dialogProps = buildProps({
* @description whether to append Dialog itself to body. A nested Dialog should have this attribute set to `true`
*/
appendToBody: Boolean,
/**
* @description which element the Dialog appends to
*/
appendTo: {
type: definePropType<string>(String),
default: 'body',
},
/**
* @description callback before Dialog closes, and it will prevent Dialog from closing, use done to close the dialog
*/

View File

@ -1,5 +1,8 @@
<template>
<teleport to="body" :disabled="!appendToBody">
<teleport
:to="appendTo"
:disabled="appendTo !== 'body' ? false : !appendToBody"
>
<transition
name="dialog-fade"
@after-enter="afterEnter"