From 3f0714cebf290c5699ed372d5b629768d59b0700 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Sat, 5 Jun 2021 21:30:39 +0800 Subject: [PATCH] fix(collapse): `default-expanded-names` not working --- CHANGELOG.en-US.md | 4 ++++ CHANGELOG.zh-CN.md | 6 ++++++ src/collapse/src/Collapse.tsx | 14 +++++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 63fa95625..5e394b64a 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -1,5 +1,9 @@ # CHANGELOG +## Pending + +- Fix `n-collapse` `default-expanded-names` not working. + ## 2.11.2 ### Fixes diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e8a45d6d1..f705261dd 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -1,5 +1,11 @@ # CHANGELOG +## Pending + +### Fixes + +- 修复 `n-collapse` `default-expanded-names` 不生效 + ## 2.11.2 ### Fixes diff --git a/src/collapse/src/Collapse.tsx b/src/collapse/src/Collapse.tsx index 4e302d421..8e0dd407c 100644 --- a/src/collapse/src/Collapse.tsx +++ b/src/collapse/src/Collapse.tsx @@ -29,9 +29,12 @@ import { const collapseProps = { ...(useTheme.props as ThemeProps), - defaultExpandesNames: [Array, String] as PropType< - string | number | Array | null - >, + defaultExpandedNames: { + type: [Array, String] as PropType< + string | number | Array | null + >, + default: null + }, expandedNames: [Array, String] as PropType< string | number | Array | null >, @@ -98,8 +101,9 @@ export default defineComponent({ props: collapseProps, setup (props, { slots }) { const { mergedClsPrefixRef } = useConfig(props) - const uncontrolledExpandedNamesRef = - ref | null>(null) + const uncontrolledExpandedNamesRef = ref< + string | number | Array | null + >(props.defaultExpandedNames) const controlledExpandedNamesRef = computed(() => props.expandedNames) const mergedExpandedNamesRef = useMergedState( controlledExpandedNamesRef,