Skip to content

Commit

Permalink
fix(modal): add v-model support for visible
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Jun 10, 2021
1 parent b387681 commit de12bab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/components/Modal/src/BasicModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader },
inheritAttrs: false,
props: basicProps,
emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register'],
emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register', 'update:visible'],
setup(props, { emit, attrs }) {
const visibleRef = ref(false);
const propsRef = ref<Partial<ModalProps> | null>(null);
Expand Down Expand Up @@ -157,6 +157,7 @@
() => unref(visibleRef),
(v) => {
emit('visible-change', v);
emit('update:visible', v);
instance && modalMethods.emitVisible?.(v, instance.uid);
nextTick(() => {
if (props.scrollTop && v && unref(modalWrapperRef)) {
Expand All @@ -180,7 +181,7 @@
}
visibleRef.value = false;
emit('cancel');
emit('cancel', e);
}
/**
Expand All @@ -193,8 +194,8 @@
visibleRef.value = !!props.visible;
}
function handleOk() {
emit('ok');
function handleOk(e: Event) {
emit('ok', e);
}
function handleHeightChange(height: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Modal/src/components/ModalClose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
];
});
function handleCancel() {
emit('cancel');
function handleCancel(e: Event) {
emit('cancel', e);
}
function handleFullScreen(e: Event) {
e?.stopPropagation();
Expand Down
8 changes: 4 additions & 4 deletions src/components/Modal/src/components/ModalFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
props: basicProps,
emits: ['ok', 'cancel'],
setup(_, { emit }) {
function handleOk() {
emit('ok');
function handleOk(e: Event) {
emit('ok', e);
}
function handleCancel() {
emit('cancel');
function handleCancel(e: Event) {
emit('cancel', e);
}
return { handleOk, handleCancel };
},
Expand Down

0 comments on commit de12bab

Please sign in to comment.