Skip to content

Commit 6525102

Browse files
authored
fix: Cascader conduction missing async value (#384)
* test: test driven * fix: TreeSelect conduction values * chore: rm useless lint
1 parent 5fb293c commit 6525102

File tree

5 files changed

+50
-10
lines changed

5 files changed

+50
-10
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module.exports = {
88
'default-case': 0,
99
'eslint-comments/disable-enable-pair': 0,
1010
'jsx-a11y/interactive-supports-focus': 0,
11-
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
1211
'@typescript-eslint/no-object-literal-type-assertion': 0,
1312
},
1413
};

examples/disable.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-named-as-default-member */
21
import '../assets/index.less';
32
import React from 'react';
43
import TreeSelect from '../src';
@@ -76,11 +75,7 @@ class Demo extends React.Component {
7675
return (
7776
<div>
7877
<TreeSelect {...tProps} />
79-
<input
80-
type="checkbox"
81-
onChange={e => this.switch(e.target.checked)}
82-
/>{' '}
83-
禁用
78+
<input type="checkbox" onChange={e => this.switch(e.target.checked)} /> 禁用
8479
</div>
8580
);
8681
}

src/generate.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@ export default function generate(config: {
325325
];
326326
}
327327
return [newRawValues, valueHalfCheckedKeys];
328-
}, [value, mergedMultiple, mergedLabelInValue, treeCheckable, treeCheckStrictly]);
328+
}, [
329+
value,
330+
flattedOptions,
331+
mergedMultiple,
332+
mergedLabelInValue,
333+
treeCheckable,
334+
treeCheckStrictly,
335+
]);
329336

330337
const selectValues = useSelectValues(rawValues, {
331338
treeConduction,

tests/Select.checkable.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,45 @@ describe('TreeSelect.checkable', () => {
712712

713713
expect(wrapper.exists('.rc-tree-select-tree-treenode-checkbox-checked')).toBeTruthy();
714714
});
715+
716+
// https://github.com/ant-design/ant-design/issues/32184
717+
it('should pass correct keys', () => {
718+
const wrapper = mount(
719+
<TreeSelect
720+
open
721+
treeCheckable
722+
showCheckedStrategy={TreeSelect.SHOW_PARENT}
723+
value={['parent']}
724+
treeData={[
725+
{
726+
label: 'parent',
727+
value: 'parent',
728+
},
729+
]}
730+
/>,
731+
);
732+
733+
expect(wrapper.find('Tree').prop('checkedKeys')).toEqual(
734+
expect.objectContaining({ checked: ['parent'] }),
735+
);
736+
737+
wrapper.setProps({
738+
treeData: [
739+
{
740+
label: 'parent',
741+
value: 'parent',
742+
children: [
743+
{
744+
label: 'child',
745+
value: 'child',
746+
},
747+
],
748+
},
749+
],
750+
});
751+
752+
expect(wrapper.find('Tree').prop('checkedKeys')).toEqual(
753+
expect.objectContaining({ checked: ['parent', 'child'] }),
754+
);
755+
});
715756
});

tests/__mocks__/rc-motion/lib/CSSMotionList.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
2-
31
import React from 'react';
42
import { genCSSMotion } from 'rc-motion/lib/CSSMotion';
53
import CSSMotionList, { genCSSMotionList } from 'rc-motion/lib/CSSMotionList';

0 commit comments

Comments
 (0)