Skip to content

Commit

Permalink
fix(tabs): 调整dragSorter声明时机
Browse files Browse the repository at this point in the history
  • Loading branch information
LzhengH committed Sep 19, 2024
1 parent a80c848 commit 8484929
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './common';
export * from './divider';
export * from './dropdown';
export * from './grid';
export * from './hooks';
export * from './image';
export * from './input';
export * from './input-number';
Expand Down
19 changes: 6 additions & 13 deletions src/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ export default class Tabs extends Component<TabsProps> {

targetClassNameRegExpStr = `^${this.tabClasses.tdTabsClassPrefix}(__nav-item|__nav-item-wrapper|__nav-item-text-wrapper)`;

dragSorter = new UseDragSorter({
...this.props,
sortOnDraggable: this.props.dragSort,
onDragOverCheck: {
x: true,
targetClassNameRegExp: new RegExp(this.targetClassNameRegExpStr),
},
});
dragSorter: UseDragSorter<TabValue> | null = null;

memoChildren = () => {
const { list, children } = this.props;
Expand Down Expand Up @@ -102,7 +95,7 @@ export default class Tabs extends Component<TabsProps> {
>
<t-tab-nav
{...this.props}
getDragProps={this.dragSorter.getDragProps}
getDragProps={this.dragSorter?.getDragProps}
activeValue={this.value}
onRemove={this.props.onRemove}
itemList={this.itemList()}
Expand All @@ -118,10 +111,6 @@ export default class Tabs extends Component<TabsProps> {
this.props.defaultValue === undefined && Array.isArray(this.itemList) && this.itemList.length !== 0
? this.itemList[0].value
: this.props.defaultValue;
}

render(props: TabsProps) {
const { className, style } = props;

this.dragSorter = new UseDragSorter({
...this.props,
Expand All @@ -131,6 +120,10 @@ export default class Tabs extends Component<TabsProps> {
targetClassNameRegExp: new RegExp(this.targetClassNameRegExpStr),
},
});
}

render(props: TabsProps) {
const { className, style } = props;

return (
<div ref={this.props.ref} className={classname(this.tabClasses.tdTabsClassPrefix, className)} style={style}>
Expand Down

0 comments on commit 8484929

Please sign in to comment.