Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/utils/strategyUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export function formatStrategyValues(
if (
entity &&
entity.children &&
entity.children.every(
({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]),
)
entity.children.every(({ node }) => valueSet.has(node[fieldNames.value]))
) {
return false;
}
Expand Down
27 changes: 22 additions & 5 deletions tests/Select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('TreeSelect.basic', () => {
{ key: '0', value: '0', title: 'label0' },
{ key: '1', value: '1', title: 'label1' },
];
const createSelect = (props) => <TreeSelect open treeData={treeData} {...props} />;
const createSelect = props => <TreeSelect open treeData={treeData} {...props} />;

it('fires change and select event', () => {
const onChange = jest.fn();
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('TreeSelect.basic', () => {
{ key: 'a', value: 'a', title: 'labela' },
{ key: 'b', value: 'b', title: 'labelb' },
];
const createSelect = (props) => <TreeSelect open showSearch treeData={treeData} {...props} />;
const createSelect = props => <TreeSelect open showSearch treeData={treeData} {...props} />;

it('renders search input', () => {
const wrapper = mount(createSelect());
Expand All @@ -228,7 +228,7 @@ describe('TreeSelect.basic', () => {
});

it('check tree changed by filter', () => {
const Wrapper = (props) => <div>{createSelect(props)}</div>;
const Wrapper = props => <div>{createSelect(props)}</div>;
const wrapper = mount(<Wrapper searchValue="a" treeDefaultExpandAll open />);
expect(wrapper.render()).toMatchSnapshot();
wrapper.setProps({ searchValue: '' });
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('TreeSelect.basic', () => {
inputValue: '0',
};

handleSearch = (inputValue) => {
handleSearch = inputValue => {
this.setState({ inputValue });
};

Expand All @@ -359,7 +359,7 @@ describe('TreeSelect.basic', () => {
});

describe('keyCode', () => {
[KeyCode.ENTER, KeyCode.DOWN].forEach((code) => {
[KeyCode.ENTER, KeyCode.DOWN].forEach(code => {
it('open', () => {
const onFocus = jest.fn();

Expand Down Expand Up @@ -502,4 +502,21 @@ describe('TreeSelect.basic', () => {
wrapper.update();
expect(wrapper.find('.rc-tree-select-selection-item').text()).toEqual('bamboo');
});

it('should show parent if children were disabled', () => {
const onSelect = jest.fn();

const wrapper = mount(
<TreeSelect open treeDefaultExpandAll onSelect={onSelect}>
<TreeNode value="parent 1-0" title="parent 1-0">
<TreeNode value="leaf1" title="my leaf" disabled />
<TreeNode value="leaf2" title="your leaf" disabled />
</TreeNode>
</TreeSelect>,
);

wrapper.selectNode();
expect(onSelect).toHaveBeenCalledWith('parent 1-0', expect.anything());
expect(wrapper.text()).toBe('parent 1-0parent 1-0my leafyour leaf');
});
});