Skip to content

Commit

Permalink
fix(List): fix SimpleContainer dimensions handle (#1479)
Browse files Browse the repository at this point in the history
  • Loading branch information
korvin89 authored Apr 3, 2024
1 parent 1ead791 commit 68243be
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
1 change: 0 additions & 1 deletion src/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ export class List<T = unknown> extends React.Component<ListProps<T>, ListState<T
ref={this.refContainer}
itemCount={items.length}
provided={droppableProvided}
sortable={sortable}
>
{items.map((_item, index) => {
return (
Expand Down
17 changes: 1 addition & 16 deletions src/components/List/components/SimpleContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import type {ListItem} from './ListItem';
export type SimpleContainerProps = React.PropsWithChildren<{
itemCount: number;
provided?: DroppableProvided;
sortable?: boolean;
}>;

type RefsList = Record<number, React.RefObject<ListItem>>;

export type SimpleContainerState = {
refsList: RefsList;
minWidth?: number;
minHeight?: number;
};

function getRefs(count: number) {
Expand Down Expand Up @@ -50,24 +47,12 @@ export class SimpleContainer extends React.Component<SimpleContainerProps, Simpl
};
}

componentDidMount() {
if (this.node && this.props.sortable) {
const {width, height} = this.node.getBoundingClientRect();
this.setState({minWidth: width, minHeight: height});
}
}

render() {
const {minWidth, minHeight} = this.state;
const children = React.Children.map(this.props.children, (child, index) =>
React.cloneElement(child as React.ReactElement, {ref: this.state.refsList[index]}),
);

return (
<div ref={this.setRef} style={{minWidth, minHeight}}>
{children}
</div>
);
return <div ref={this.setRef}>{children}</div>;
}

scrollToItem(index: number) {
Expand Down

0 comments on commit 68243be

Please sign in to comment.