Skip to content

Commit 093f07c

Browse files
authored
feat(vc-collapse): key support number type #4405 (#4474)
close #4405
1 parent 881a796 commit 093f07c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

components/vc-collapse/src/Collapse.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import openAnimationFactory from './openAnimationFactory';
1111
import { collapseProps } from './commonProps';
1212
import { getDataAndAriaProps } from '../../_util/util';
1313
import { defineComponent } from 'vue';
14+
import isNil from 'lodash/isNil';
1415

1516
function _toArray(activeKey) {
1617
let currentActiveKey = activeKey;
1718
if (!Array.isArray(currentActiveKey)) {
18-
currentActiveKey = currentActiveKey ? [currentActiveKey] : [];
19+
const activeKeyType = typeof currentActiveKey;
20+
currentActiveKey =
21+
activeKeyType === 'number' || activeKeyType === 'string' ? [currentActiveKey] : [];
1922
}
2023
return currentActiveKey.map(key => String(key));
2124
}
@@ -76,7 +79,7 @@ export default defineComponent({
7679
const { prefixCls, accordion, destroyInactivePanel, expandIcon } = this.$props;
7780

7881
// If there is no key provide, use the panel order as default key
79-
const key = child.key || String(index);
82+
const key = !isNil(child.key) ? String(child.key) : String(index);
8083
const { header, headerClass, disabled } = getPropsData(child);
8184
let isActive = false;
8285

0 commit comments

Comments
 (0)