From 450afb79205011b98948f49bb9a205aa69b577fa Mon Sep 17 00:00:00 2001 From: leidenglai <819441338@qq.com> Date: Mon, 27 Apr 2020 13:14:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(accordion):=20Accordion=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AF=E7=9A=84=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=97=B6=20state=20height=20=E5=88=9D=E5=A7=8B=E4=B8=BA0=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=8A=A8=E7=94=BB=E9=94=99=E8=AF=AF=EF=BC=8C?= =?UTF-8?q?=E5=B0=86height=E5=88=9D=E5=A7=8B=E8=AE=BE=E7=BD=AE=E4=B8=BAuns?= =?UTF-8?q?et?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/accordion/index.tsx | 7 ++++--- types/accordion.d.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/accordion/index.tsx b/src/components/accordion/index.tsx index e822ef247..0c0442a50 100644 --- a/src/components/accordion/index.tsx +++ b/src/components/accordion/index.tsx @@ -25,7 +25,7 @@ export default class AtAccordion extends AtComponent< this.isCompleted = true this.startOpen = false this.state = { - wrapperHeight: 0 + wrapperHeight: 'unset' } } @@ -109,8 +109,9 @@ export default class AtAccordion extends AtComponent< color: (icon && icon.color) || '', fontSize: (icon && `${icon.size}px`) || '' } - const contentStyle = { height: `${wrapperHeight}px` } - + const contentStyle = { + height: wrapperHeight === 'unset' ? wrapperHeight : `${wrapperHeight}px` + } if (this.isCompleted) { contentStyle.height = '' } diff --git a/types/accordion.d.ts b/types/accordion.d.ts index 5f9d819a1..81dfc0309 100644 --- a/types/accordion.d.ts +++ b/types/accordion.d.ts @@ -40,7 +40,7 @@ export interface AtAccordionProps extends AtComponent { } export interface AtAccordionState { - wrapperHeight: number + wrapperHeight: number | 'unset' } declare const AtAccordion: ComponentClass