From f504245074fb0450ec69f5c64577be2716b80ac4 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 26 Oct 2020 20:47:43 +0800 Subject: [PATCH 1/6] fix(Tabs): should scroll to current content when mounted (#7411) --- src/tabs/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tabs/index.js b/src/tabs/index.js index da2af15a0..44126579d 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -189,6 +189,7 @@ export default createComponent({ this.inited = true; this.tabHeight = getVisibleHeight(this.$refs.wrap); this.scrollIntoView(true); + this.scrollToCurrentContent(true); }); }, From e9a21d4815fa6af83cc1580ecfe8f27067a3c99d Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 27 Oct 2020 17:27:01 +0800 Subject: [PATCH 2/6] style(Popup): adjust round border radius to 16px (#7421) --- src/style/var.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/var.less b/src/style/var.less index 332bc6c5d..1599fe253 100644 --- a/src/style/var.less +++ b/src/style/var.less @@ -558,7 +558,7 @@ // Popup @popup-background-color: @white; @popup-transition: transform @animation-duration-base; -@popup-round-border-radius: 20px; +@popup-round-border-radius: 16px; @popup-close-icon-size: 22px; @popup-close-icon-color: @gray-5; @popup-close-icon-active-color: @gray-6; From 71452190a8d56bfa8d97267978471617d313e7ea Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 28 Oct 2020 18:21:06 +0800 Subject: [PATCH 3/6] fix(GridItem): should not emit deprecation warning (#7433) --- src/grid-item/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grid-item/index.js b/src/grid-item/index.js index e9be76851..974d0e8f4 100644 --- a/src/grid-item/index.js +++ b/src/grid-item/index.js @@ -94,7 +94,7 @@ export default createComponent({ Date: Wed, 28 Oct 2020 21:04:23 +0800 Subject: [PATCH 4/6] style(action-sheet): make sure the layout is correct when actions is to much (#7401) --- src/action-sheet/index.less | 19 ++++++ src/action-sheet/index.tsx | 14 ++-- .../test/__snapshots__/index.spec.js.snap | 68 ++++++++++++++----- 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/src/action-sheet/index.less b/src/action-sheet/index.less index 3a776e4f7..d8b9fe81f 100644 --- a/src/action-sheet/index.less +++ b/src/action-sheet/index.less @@ -2,7 +2,10 @@ @import '../style/mixins/hairline'; .van-action-sheet { + display: flex; + flex-direction: column; max-height: @action-sheet-max-height; + overflow: hidden; color: @action-sheet-item-text-color; &__item, @@ -42,6 +45,8 @@ } &__cancel { + flex-shrink: 0; + box-sizing: border-box; color: @action-sheet-cancel-text-color; } @@ -59,6 +64,7 @@ } &__header { + flex-shrink: 0; font-weight: @font-weight-bold; font-size: @action-sheet-header-font-size; line-height: @action-sheet-header-height; @@ -67,6 +73,7 @@ &__description { position: relative; + flex-shrink: 0; padding: 20px @padding-md; color: @action-sheet-description-color; font-size: @action-sheet-description-font-size; @@ -96,4 +103,16 @@ color: @action-sheet-close-icon-active-color; } } + + &__inner { + display: flex; + flex: 1; + flex-direction: column; + overflow: hidden; + } + + &__main { + flex: 1; + overflow-y: scroll; + } } diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index bf91976a4..94f77860d 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -159,11 +159,15 @@ function ActionSheet( safeAreaInsetBottom={props.safeAreaInsetBottom} {...inherit(ctx, true)} > - {Header()} - {Description()} - {props.actions && props.actions.map(Option)} - {Content()} - {CancelText()} +
+ {Header()} + {Description()} +
+ {props.actions && props.actions.map(Option)} + {Content()} +
+ {CancelText()} +
); } diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index a5685dfb5..95fde23d8 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -1,53 +1,87 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`callback events 1`] = ` -
-
+
+
+
+
+
`; exports[`close-icon prop 1`] = `
-
Title -
+
+
Title +
+
+
`; exports[`closeable prop 1`] = `
-
Title
+
+
Title
+
+
`; -exports[`color option 1`] = `
`; +exports[`color option 1`] = ` +
+
+
+
+
+`; exports[`description prop 1`] = `
-
This is a description
+
+
This is a description
+
+
`; exports[`description slot 1`] = `
-
Custom Description
+
+
Custom Description
+
+
`; exports[`disable lazy-render 1`] = ` -
`; + +exports[`insert tab with name dynamically 1`] = ` +
+
+
+ + +
+
+
+
+ +
1
+
+
+`; diff --git a/src/tab/test/insert.spec.js b/src/tab/test/insert.spec.js index bfd4a3edb..3c28b4053 100644 --- a/src/tab/test/insert.spec.js +++ b/src/tab/test/insert.spec.js @@ -26,6 +26,27 @@ test('insert tab dynamically', async () => { expect(wrapper).toMatchSnapshot(); }); +test('insert tab with name dynamically', async () => { + const wrapper = mount({ + template: ` + + 2 + 1 + + `, + data() { + return { + insert: false, + active: [{ name: 'foo', title: 'foo' }], + }; + }, + }); + + await later(); + wrapper.setData({ insert: true }); + expect(wrapper).toMatchSnapshot(); +}); + // this case will throw wierd error in index.spec.js // so separate it test('insert tab with child component', async () => { diff --git a/src/tabs/index.js b/src/tabs/index.js index 44126579d..496790e62 100644 --- a/src/tabs/index.js +++ b/src/tabs/index.js @@ -142,7 +142,7 @@ export default createComponent({ }, children() { - this.setCurrentIndexByName(this.currentName || this.active); + this.setCurrentIndexByName(this.active || this.currentName); this.setLine(); this.$nextTick(() => { From 0cb55c33e06bec985f77100fa4fdff0c34254c2d Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 29 Oct 2020 21:57:11 +0800 Subject: [PATCH 6/6] chore(ActionSheet): optimize dom (#7434) * chore(ActionSheet): optimize dom * chore: update snapshot --- src/action-sheet/index.less | 18 ++---- src/action-sheet/index.tsx | 20 ++---- .../test/__snapshots__/index.spec.js.snap | 62 +++++++------------ 3 files changed, 33 insertions(+), 67 deletions(-) diff --git a/src/action-sheet/index.less b/src/action-sheet/index.less index d8b9fe81f..9928c7bcb 100644 --- a/src/action-sheet/index.less +++ b/src/action-sheet/index.less @@ -8,6 +8,12 @@ overflow: hidden; color: @action-sheet-item-text-color; + &__content { + flex: 1; + overflow-y: auto; + -webkit-overflow-scrolling: touch; + } + &__item, &__cancel { display: block; @@ -103,16 +109,4 @@ color: @action-sheet-close-icon-active-color; } } - - &__inner { - display: flex; - flex: 1; - flex-direction: column; - overflow: hidden; - } - - &__main { - flex: 1; - overflow-y: scroll; - } } diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index 94f77860d..590bd90b3 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -75,12 +75,6 @@ function ActionSheet( } } - function Content() { - if (slots.default) { - return
{slots.default()}
; - } - } - function Option(item: ActionSheetItem, index: number) { const { disabled, loading, callback } = item; @@ -159,15 +153,13 @@ function ActionSheet( safeAreaInsetBottom={props.safeAreaInsetBottom} {...inherit(ctx, true)} > -
- {Header()} - {Description()} -
- {props.actions && props.actions.map(Option)} - {Content()} -
- {CancelText()} + {Header()} + {Description()} +
+ {props.actions && props.actions.map(Option)} + {slots.default?.()}
+ {CancelText()} ); } diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index 95fde23d8..932b1a226 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -2,86 +2,66 @@ exports[`callback events 1`] = `
-
-
-
-
+
+
`; exports[`close-icon prop 1`] = `
-
-
Title -
-
-
+
Title +
+
`; exports[`closeable prop 1`] = `
-
-
Title
-
-
+
Title
+
`; exports[`color option 1`] = `
-
-
-
+
`; exports[`description prop 1`] = `
-
-
This is a description
-
-
+
This is a description
+
`; exports[`description slot 1`] = `
-
-
Custom Description
-
-
+
Custom Description
+
`; exports[`disable lazy-render 1`] = ` `; exports[`render title and default slot 1`] = `
-
-
Title -
-
-
Default
-
-
+
Title +
+
Default
`; exports[`round prop 1`] = `
-
-
-
+
`;