Skip to content

Commit

Permalink
fix: fixed an error caused by dragging under the headerCell slot. (#…
Browse files Browse the repository at this point in the history
…7291)

* fix: fix headerCell slots

* perf: optimize table columnTitle type
  • Loading branch information
cc-hearts authored Jan 30, 2024
1 parent 0cbf3ca commit 7c73beb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/table/hooks/useColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import devWarning from '../../vc-util/devWarning';
import { renderSlot } from 'vue';
import type { Ref } from 'vue';
import type { ContextSlots } from '../context';
import type { TransformColumns, ColumnsType } from '../interface';
import { SELECTION_COLUMN } from './useSelection';
import { EXPAND_COLUMN } from '../../vc-table';
import { customRenderSlot } from '../../_util/vnode';

function fillSlots<RecordType>(columns: ColumnsType<RecordType>, contextSlots: Ref<ContextSlots>) {
const $slots = contextSlots.value;
Expand All @@ -27,7 +27,7 @@ function fillSlots<RecordType>(columns: ColumnsType<RecordType>, contextSlots: R
});

if (contextSlots.value.headerCell && !column.slots?.title) {
cloneColumn.title = renderSlot(
cloneColumn.title = customRenderSlot(
contextSlots.value,
'headerCell',
{
Expand Down
7 changes: 5 additions & 2 deletions components/table/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Breakpoint } from '../_util/responsiveObserve';
import type { INTERNAL_SELECTION_ITEM } from './hooks/useSelection';
import type { VueNode } from '../_util/type';
import { tuple } from '../_util/type';
import type { CSSProperties } from 'vue';
import type { CSSProperties, VNodeArrayChildren } from 'vue';
// import { TableAction } from './Table';

export type { GetRowKey, ExpandableConfig };
Expand Down Expand Up @@ -68,7 +68,10 @@ export interface ColumnTitleProps<RecordType> {
filters?: Record<string, FilterValue>;
}

export type ColumnTitle<RecordType> = VueNode | ((props: ColumnTitleProps<RecordType>) => VueNode);
type ColumnTitleNode = VueNode | VNodeArrayChildren;
export type ColumnTitle<RecordType> =
| ColumnTitleNode
| ((props: ColumnTitleProps<RecordType>) => ColumnTitleNode);

export type FilterValue = (Key | boolean)[];
export type FilterKey = Key[] | null;
Expand Down

0 comments on commit 7c73beb

Please sign in to comment.