Skip to content

Commit

Permalink
feat:[Tree] selected background color is gray when the node is disabl…
Browse files Browse the repository at this point in the history
…ed (ant-design#52173)

* feat:[Tree]对不可check的文本,select时候背景色改为灰色

* feat:[Tree] 修改disabled 选中的文本背景颜色

* feat: 对整行disable 的文本调整select背景色

* fix:恢复误改内容

* feat:删除不需要的多增加的注释内容

* feat:合并css选择器

* feat:更新 Tree snapshot

* feat:删除不需要的提交

---------

Co-authored-by: 刘欢 <[email protected]>
Co-authored-by: afc163 <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2025
1 parent 8164b9e commit 2a21f7b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
12 changes: 6 additions & 6 deletions components/tree/__tests__/__snapshots__/demo-extend.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ exports[`renders components/tree/demo/basic.tsx extend context correctly 1`] = `
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked"
draggable="false"
>
<span
Expand Down Expand Up @@ -218,7 +218,7 @@ exports[`renders components/tree/demo/basic.tsx extend context correctly 1`] = `
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected ant-tree-treenode-leaf-last"
draggable="false"
>
<span
Expand Down Expand Up @@ -260,7 +260,7 @@ exports[`renders components/tree/demo/basic.tsx extend context correctly 1`] = `
/>
</span>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open"
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open ant-tree-node-selected"
title="parent 1-1"
>
<span
Expand Down Expand Up @@ -4120,7 +4120,7 @@ exports[`renders components/tree/demo/multiple-line.tsx extend context correctly
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked"
draggable="false"
>
<span
Expand Down Expand Up @@ -4248,7 +4248,7 @@ exports[`renders components/tree/demo/multiple-line.tsx extend context correctly
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected ant-tree-treenode-leaf-last"
draggable="false"
>
<span
Expand Down Expand Up @@ -4290,7 +4290,7 @@ exports[`renders components/tree/demo/multiple-line.tsx extend context correctly
/>
</span>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open"
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open ant-tree-node-selected"
title="parent 1-1"
>
<span
Expand Down
12 changes: 6 additions & 6 deletions components/tree/__tests__/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ exports[`renders components/tree/demo/basic.tsx correctly 1`] = `
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked"
draggable="false"
>
<span
Expand Down Expand Up @@ -218,7 +218,7 @@ exports[`renders components/tree/demo/basic.tsx correctly 1`] = `
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected ant-tree-treenode-leaf-last"
draggable="false"
>
<span
Expand Down Expand Up @@ -260,7 +260,7 @@ exports[`renders components/tree/demo/basic.tsx correctly 1`] = `
/>
</span>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open"
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open ant-tree-node-selected"
title="parent 1-1"
>
<span
Expand Down Expand Up @@ -4005,7 +4005,7 @@ exports[`renders components/tree/demo/multiple-line.tsx correctly 1`] = `
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected"
class="ant-tree-treenode ant-tree-treenode-disabled ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked"
draggable="false"
>
<span
Expand Down Expand Up @@ -4133,7 +4133,7 @@ exports[`renders components/tree/demo/multiple-line.tsx correctly 1`] = `
</div>
<div
aria-grabbed="false"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-leaf-last"
class="ant-tree-treenode ant-tree-treenode-switcher-open ant-tree-treenode-checkbox-checked ant-tree-treenode-selected ant-tree-treenode-leaf-last"
draggable="false"
>
<span
Expand Down Expand Up @@ -4175,7 +4175,7 @@ exports[`renders components/tree/demo/multiple-line.tsx correctly 1`] = `
/>
</span>
<span
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open"
class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open ant-tree-node-selected"
title="parent 1-1"
>
<span
Expand Down
2 changes: 1 addition & 1 deletion components/tree/demo/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const App: React.FC = () => {
<Tree
checkable
defaultExpandedKeys={['0-0-0', '0-0-1']}
defaultSelectedKeys={['0-0-0', '0-0-1']}
defaultSelectedKeys={['0-0-1']}
defaultCheckedKeys={['0-0-0', '0-0-1']}
onSelect={onSelect}
onCheck={onCheck}
Expand Down
2 changes: 1 addition & 1 deletion components/tree/demo/component-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const App: React.FC = () => {
<Tree
checkable
defaultExpandedKeys={['0-0-0', '0-0-1']}
defaultSelectedKeys={['0-0-0', '0-0-1']}
defaultSelectedKeys={['0-0-1']}
defaultCheckedKeys={['0-0-0', '0-0-1']}
onSelect={onSelect}
onCheck={onCheck}
Expand Down
6 changes: 3 additions & 3 deletions components/tree/demo/directory-debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const treeData: TreeDataNode[] = [
title: 'parent 0',
key: '0-0',
children: [
{ title: 'leaf 0-0', key: '0-0-0', isLeaf: true },
{ title: 'leaf 0-1', key: '0-0-1', isLeaf: true },
{ title: 'leaf 0-0', key: '0-0-0', isLeaf: true, disabled: true },
{ title: 'leaf 0-1', key: '0-0-1', isLeaf: true, disableCheckbox: true },
],
},
{
Expand Down Expand Up @@ -46,7 +46,7 @@ const BasicDemo = () => <DirectoryTree {...sharedProps} multiple treeData={treeD

const NormalDemo = () => <Tree {...sharedProps} defaultSelectedKeys={['0-1']} />;

const NormalCheckDemo = () => <Tree {...sharedProps} checkable defaultSelectedKeys={['0-1']} />;
const NormalCheckDemo = () => <Tree {...sharedProps} checkable defaultSelectedKeys={['0-1','0-0-0', '0-0-1','0-1-1']} />;

const NormalDragDemo = () => <Tree {...sharedProps} draggable defaultSelectedKeys={['0-1-0']} />;

Expand Down
2 changes: 1 addition & 1 deletion components/tree/demo/multiple-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const App: React.FC = () => {
<Tree
checkable
defaultExpandedKeys={['0-0-0', '0-0-1']}
defaultSelectedKeys={['0-0-0', '0-0-1']}
defaultSelectedKeys={['0-0-1']}
defaultCheckedKeys={['0-0-0', '0-0-1']}
onSelect={onSelect}
onCheck={onCheck}
Expand Down
7 changes: 6 additions & 1 deletion components/tree/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
nodeSelectedBg,
nodeHoverBg,
colorTextQuaternary,
controlItemBgActiveDisabled,
} = token;

return {
[treeCls]: {
...resetComponent(token),
Expand Down Expand Up @@ -199,6 +199,11 @@ export const genBaseStyle = (prefixCls: string, token: TreeToken): CSSObject =>
},
},

[`${treeCls}-checkbox-disabled + ${treeCls}-node-selected,&${treeNodeCls}-disabled${treeNodeCls}-selected ${treeCls}-node-content-wrapper`]:
{
backgroundColor: controlItemBgActiveDisabled,
},

// not disable
[`&:not(${treeNodeCls}-disabled)`]: {
// >>> Title
Expand Down

0 comments on commit 2a21f7b

Please sign in to comment.