fix: tree-select not disable parent cannot checked, close #5316

pull/5333/head
tangjinzhou 3 years ago
parent f7e89998e9
commit 5dd7a57734

@ -151,13 +151,16 @@ export default defineComponent({
// >>> Select item // >>> Select item
case KeyCode.ENTER: { case KeyCode.ENTER: {
const { selectable, value } = activeEntity.value?.node || {}; if (activeEntity.value) {
if (activeEntity.value && selectable !== false) { const { selectable, value } = activeEntity.value.node || {};
onInternalSelect(null, { if (selectable !== false) {
node: { key: activeKey.value }, onInternalSelect(null, {
selected: !legacyContext.checkedKeys.includes(value), node: { key: activeKey.value },
}); selected: !legacyContext.checkedKeys.includes(value),
});
}
} }
break; break;
} }
@ -233,6 +236,7 @@ export default defineComponent({
showLine={treeLine} showLine={treeLine}
loadData={searchValue ? null : (loadData as any)} loadData={searchValue ? null : (loadData as any)}
motion={treeMotion} motion={treeMotion}
activeKey={activeKey.value}
// We handle keys by out instead tree self // We handle keys by out instead tree self
checkable={checkable} checkable={checkable}
checkStrictly checkStrictly

@ -387,7 +387,15 @@ export default defineComponent({
const values = displayKeys.map( const values = displayKeys.map(
key => keyEntities.value[key]?.node?.[mergedFieldNames.value.value] ?? key, key => keyEntities.value[key]?.node?.[mergedFieldNames.value.value] ?? key,
); );
const rawDisplayValues = convert2LabelValues(values); // Back fill with origin label
const labeledValues = values.map(val => {
const targetItem = rawLabeledValues.value.find(item => item.value === val);
return {
value: val,
label: targetItem?.label,
};
});
const rawDisplayValues = convert2LabelValues(labeledValues);
const firstVal = rawDisplayValues[0]; const firstVal = rawDisplayValues[0];
@ -728,6 +736,7 @@ export default defineComponent({
emptyOptions={!mergedTreeData.value.length} emptyOptions={!mergedTreeData.value.length}
onDropdownVisibleChange={onInternalDropdownVisibleChange} onDropdownVisibleChange={onInternalDropdownVisibleChange}
tagRender={props.tagRender || slots.tagRender} tagRender={props.tagRender || slots.tagRender}
dropdownMatchSelectWidth={props.dropdownMatchSelectWidth ?? true}
/> />
); );
}; };

@ -1,4 +1,4 @@
// base rc-tree-select@5.0.0-alpha.4 // base rc-tree-select@5.1.4
import type { TreeSelectProps } from './TreeSelect'; import type { TreeSelectProps } from './TreeSelect';
import TreeSelect, { treeSelectProps } from './TreeSelect'; import TreeSelect, { treeSelectProps } from './TreeSelect';
import TreeNode from './TreeNode'; import TreeNode from './TreeNode';

@ -24,6 +24,7 @@ export function formatStrategyValues(
if ( if (
entity && entity &&
entity.children && entity.children &&
entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) &&
entity.children.every( entity.children.every(
({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]), ({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]),
) )

Loading…
Cancel
Save