From 0cb55c33e06bec985f77100fa4fdff0c34254c2d Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 29 Oct 2020 21:57:11 +0800 Subject: [PATCH] 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`] = `
-
-
-
+
`;