Commit de12babd314ac831d3cb645f42dbf8a476075623
1 parent
b387681c
fix(modal): add v-model support for visible
Showing
3 changed files
with
11 additions
and
10 deletions
src/components/Modal/src/BasicModal.vue
... | ... | @@ -81,7 +81,7 @@ |
81 | 81 | components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader }, |
82 | 82 | inheritAttrs: false, |
83 | 83 | props: basicProps, |
84 | - emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register'], | |
84 | + emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register', 'update:visible'], | |
85 | 85 | setup(props, { emit, attrs }) { |
86 | 86 | const visibleRef = ref(false); |
87 | 87 | const propsRef = ref<Partial<ModalProps> | null>(null); |
... | ... | @@ -157,6 +157,7 @@ |
157 | 157 | () => unref(visibleRef), |
158 | 158 | (v) => { |
159 | 159 | emit('visible-change', v); |
160 | + emit('update:visible', v); | |
160 | 161 | instance && modalMethods.emitVisible?.(v, instance.uid); |
161 | 162 | nextTick(() => { |
162 | 163 | if (props.scrollTop && v && unref(modalWrapperRef)) { |
... | ... | @@ -180,7 +181,7 @@ |
180 | 181 | } |
181 | 182 | |
182 | 183 | visibleRef.value = false; |
183 | - emit('cancel'); | |
184 | + emit('cancel', e); | |
184 | 185 | } |
185 | 186 | |
186 | 187 | /** |
... | ... | @@ -193,8 +194,8 @@ |
193 | 194 | visibleRef.value = !!props.visible; |
194 | 195 | } |
195 | 196 | |
196 | - function handleOk() { | |
197 | - emit('ok'); | |
197 | + function handleOk(e: Event) { | |
198 | + emit('ok', e); | |
198 | 199 | } |
199 | 200 | |
200 | 201 | function handleHeightChange(height: string) { | ... | ... |
src/components/Modal/src/components/ModalClose.vue
src/components/Modal/src/components/ModalFooter.vue
... | ... | @@ -26,12 +26,12 @@ |
26 | 26 | props: basicProps, |
27 | 27 | emits: ['ok', 'cancel'], |
28 | 28 | setup(_, { emit }) { |
29 | - function handleOk() { | |
30 | - emit('ok'); | |
29 | + function handleOk(e: Event) { | |
30 | + emit('ok', e); | |
31 | 31 | } |
32 | 32 | |
33 | - function handleCancel() { | |
34 | - emit('cancel'); | |
33 | + function handleCancel(e: Event) { | |
34 | + emit('cancel', e); | |
35 | 35 | } |
36 | 36 | return { handleOk, handleCancel }; |
37 | 37 | }, | ... | ... |