fix(Calendar): content disappeared when hiding (#10910)

* fix(Calendar): content disappeared when hiding

* chore: add comment

* chore: upd
This commit is contained in:
neverland 2022-08-13 13:24:12 +08:00 committed by GitHub
parent e5cc32ca97
commit 04494a450d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -185,10 +185,6 @@ export default defineComponent({
const months: Date[] = [];
const cursor = new Date(props.minDate);
if (props.lazyRender && !props.show && props.poppable) {
return months;
}
cursor.setDate(1);
do {

View File

@ -1,5 +1,6 @@
import { useRect } from '@vant/use';
import { Ref, ref, onMounted, nextTick } from 'vue';
import { onPopupReopen } from './on-popup-reopen';
export const useHeight = (
element: Element | Ref<Element | undefined>,
@ -25,5 +26,11 @@ export const useHeight = (
}
});
// The result of useHeight might be 0 when the popup is hidden,
// so we need to reset the height when the popup is reopened.
// IntersectionObserver is a better solution, but it is not supported by legacy browsers.
// https://github.com/vant-ui/vant/issues/10628
onPopupReopen(() => nextTick(setHeight));
return height;
};