From 220efc05cae11ea986e145b2bc5941d1e7bc77be Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 6 Mar 2022 10:54:22 +0800 Subject: [PATCH] feat(Popup): add safe-area-inset-top prop (#10357) --- packages/vant/src/popup/Popup.tsx | 8 +++++-- packages/vant/src/popup/README.md | 1 + packages/vant/src/popup/README.zh-CN.md | 1 + packages/vant/src/popup/test/index.spec.jsx | 24 +++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/vant/src/popup/Popup.tsx b/packages/vant/src/popup/Popup.tsx index a8235a6be..ec73d92e8 100644 --- a/packages/vant/src/popup/Popup.tsx +++ b/packages/vant/src/popup/Popup.tsx @@ -48,6 +48,7 @@ const popupProps = extend({}, popupSharedProps, { iconPrefix: String, closeOnPopstate: Boolean, closeIconPosition: makeStringProp('top-right'), + safeAreaInsetTop: Boolean, safeAreaInsetBottom: Boolean, }); @@ -177,7 +178,7 @@ export default defineComponent({ const onKeydown = (event: KeyboardEvent) => emit('keydown', event); const renderPopup = lazyRender(() => { - const { round, position, safeAreaInsetBottom } = props; + const { round, position, safeAreaInsetTop, safeAreaInsetBottom } = props; return (
{ await wrapper.setProps({ show: false }); expect(beforeClose).toHaveBeenCalledTimes(0); }); + +test('should have safe-area-inset-top class when using safe-area-inset-top prop', () => { + const wrapper = mount(Popup, { + props: { + show: true, + safeAreaInsetTop: true, + }, + }); + + expect(wrapper.find('.van-popup').classes()).toContain('van-safe-area-top'); +}); + +test('should have safe-area-inset-bottom class when using safe-area-inset-bottom prop', () => { + const wrapper = mount(Popup, { + props: { + show: true, + safeAreaInsetBottom: true, + }, + }); + + expect(wrapper.find('.van-popup').classes()).toContain( + 'van-safe-area-bottom' + ); +});