Skip to content

revert: indentWidth prop #832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2024
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
8 changes: 0 additions & 8 deletions docs/demo/custom-indent-width.md

This file was deleted.

70 changes: 0 additions & 70 deletions docs/examples/custom-indent-width.jsx

This file was deleted.

10 changes: 2 additions & 8 deletions src/Indent.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import * as React from 'react';
import classNames from 'classnames';
import * as React from 'react';

interface IndentProps {
prefixCls: string;
level: number;
isStart: boolean[];
isEnd: boolean[];
width?: number
}

const Indent: React.FC<IndentProps> = ({ prefixCls, level, isStart, isEnd, width }) => {
const widthStyle: React.CSSProperties = width >= 0 ? {
width: width
} : {}

const Indent: React.FC<IndentProps> = ({ prefixCls, level, isStart, isEnd }) => {
const baseClassName = `${prefixCls}-indent-unit`;
const list: React.ReactElement[] = [];
for (let i = 0; i < level; i += 1) {
Expand All @@ -24,7 +19,6 @@ const Indent: React.FC<IndentProps> = ({ prefixCls, level, isStart, isEnd, width
[`${baseClassName}-start`]: isStart[i],
[`${baseClassName}-end`]: isEnd[i],
})}
style={widthStyle}
/>,
);
}
Expand Down
3 changes: 0 additions & 3 deletions src/NodeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ interface NodeListProps<TreeDataType extends BasicDataNode> {
checkable?: boolean;
selectable?: boolean;
disabled?: boolean;
indentWidth?: number;

expandedKeys: Key[];
selectedKeys: Key[];
Expand Down Expand Up @@ -150,7 +149,6 @@ const NodeList = React.forwardRef<NodeListRef, NodeListProps<any>>((props, ref)
halfCheckedKeys,
keyEntities,
disabled,
indentWidth,

dragging,
dragOverNodeKey,
Expand Down Expand Up @@ -364,7 +362,6 @@ const NodeList = React.forwardRef<NodeListRef, NodeListProps<any>>((props, ref)
isStart={isStart}
isEnd={isEnd}
motion={motion}
indentWidth={indentWidth}
motionNodes={key === MOTION_KEY ? transitionRange : null}
motionType={motionType}
onMotionStart={onListChangeStart}
Expand Down
4 changes: 0 additions & 4 deletions src/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export interface TreeProps<TreeDataType extends BasicDataNode = DataNode> {
showLine?: boolean;
showIcon?: boolean;
icon?: IconType;
indentWidth?: number;
selectable?: boolean;
expandAction?: ExpandAction;
disabled?: boolean;
Expand Down Expand Up @@ -1373,7 +1372,6 @@ class Tree<TreeDataType extends DataNode | BasicDataNode = DataNode> extends Rea
selectable,
showIcon,
icon,
indentWidth,
switcherIcon,
draggable,
checkable,
Expand Down Expand Up @@ -1432,7 +1430,6 @@ class Tree<TreeDataType extends DataNode | BasicDataNode = DataNode> extends Rea
dropPosition,
dragOverNodeKey,
indent,
indentWidth,
direction,
dropIndicatorRender,

Expand Down Expand Up @@ -1475,7 +1472,6 @@ class Tree<TreeDataType extends DataNode | BasicDataNode = DataNode> extends Rea
disabled={disabled}
selectable={selectable}
checkable={!!checkable}
indentWidth={indentWidth}
motion={motion}
dragging={draggingNodeKey !== null}
height={height}
Expand Down
2 changes: 0 additions & 2 deletions src/TreeNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ class InternalTreeNode extends React.Component<InternalTreeNodeProps, TreeNodeSt
data,
onMouseMove,
selectable,
indentWidth,
...otherProps
} = this.props;
const {
Expand Down Expand Up @@ -585,7 +584,6 @@ class InternalTreeNode extends React.Component<InternalTreeNodeProps, TreeNodeSt
level={level}
isStart={isStart}
isEnd={isEnd}
width={indentWidth}
/>
{this.renderDragHandler()}
{this.renderSwitcher()}
Expand Down
1 change: 0 additions & 1 deletion src/contextTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export interface TreeContextProps<TreeDataType extends BasicDataNode = DataNode>
dropTargetKey: Key | null;
dropPosition: -1 | 0 | 1 | null;
indent: number | null;
indentWidth?: number;
dropIndicatorRender: (props: {
dropPosition: -1 | 0 | 1;
dropLevelOffset: number;
Expand Down
1 change: 0 additions & 1 deletion src/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface TreeNodeProps<TreeDataType extends BasicDataNode = DataNode> {
isEnd?: boolean[];
active?: boolean;
onMouseMove?: React.MouseEventHandler<HTMLDivElement>;
indentWidth?: number

// By user
isLeaf?: boolean;
Expand Down
16 changes: 1 addition & 15 deletions tests/TreeProps.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ describe('Tree Props', () => {

// https://github.com/ant-design/ant-design/issues/48796
it('skip load if has children', () => {
const loadData = jest.fn(async (info) => {
const loadData = jest.fn(async info => {
console.log('->', info.key);
});

Expand Down Expand Up @@ -722,20 +722,6 @@ describe('Tree Props', () => {
);
});

it('indentWidth', () => {
const { container } = render(
<Tree defaultExpandAll indentWidth={200}>
<TreeNode key="0-0" title="parent">
<TreeNode key="0-0-0" title="child" />
</TreeNode>
</Tree>,
);

expect(getComputedStyle(container.querySelector('.rc-tree-indent-unit-start')).width).toBe(
'200px',
);
});

it('onDoubleClick', () => {
const onClick = jest.fn();
const onDoubleClick = jest.fn();
Expand Down
Loading