perf: improve modal and drawer component documentation and fix known problems (#4264)
* feat: improve modal and drawer component documentation and fix known problems * chore: update ci
This commit is contained in:
@@ -38,7 +38,6 @@ export class DrawerApi {
|
||||
isOpen: false,
|
||||
loading: false,
|
||||
modal: true,
|
||||
sharedData: {},
|
||||
title: '',
|
||||
};
|
||||
|
||||
@@ -93,7 +92,11 @@ export class DrawerApi {
|
||||
* 取消操作
|
||||
*/
|
||||
onCancel() {
|
||||
this.api.onCancel?.();
|
||||
if (this.api.onCancel) {
|
||||
this.api.onCancel?.();
|
||||
} else {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import type { DrawerProps, ExtendedDrawerApi } from './drawer';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useIsMobile, usePriorityValue } from '@vben-core/composables';
|
||||
import { Info, X } from '@vben-core/icons';
|
||||
import {
|
||||
@@ -31,6 +33,8 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
drawerApi: undefined,
|
||||
});
|
||||
|
||||
const wrapperRef = ref<HTMLElement>();
|
||||
|
||||
const { isMobile } = useIsMobile();
|
||||
const state = props.drawerApi?.useStore?.();
|
||||
|
||||
@@ -47,6 +51,18 @@ const confirmText = usePriorityValue('confirmText', props, state);
|
||||
const closeOnClickModal = usePriorityValue('closeOnClickModal', props, state);
|
||||
const closeOnPressEscape = usePriorityValue('closeOnPressEscape', props, state);
|
||||
|
||||
watch(
|
||||
() => showLoading.value,
|
||||
(v) => {
|
||||
if (v && wrapperRef.value) {
|
||||
wrapperRef.value.scrollTo({
|
||||
// behavior: 'smooth',
|
||||
top: 0,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
function interactOutside(e: Event) {
|
||||
if (!closeOnClickModal.value) {
|
||||
e.preventDefault();
|
||||
@@ -129,9 +145,10 @@ function pointerDownOutside(e: Event) {
|
||||
</SheetHeader>
|
||||
|
||||
<div
|
||||
ref="wrapperRef"
|
||||
:class="
|
||||
cn('relative flex-1 p-3', contentClass, {
|
||||
'overflow-y-auto': !showLoading,
|
||||
cn('relative flex-1 overflow-y-auto p-3', contentClass, {
|
||||
'overflow-hidden': showLoading,
|
||||
})
|
||||
"
|
||||
>
|
||||
|
Reference in New Issue
Block a user