Skip to content
Open
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
31 changes: 17 additions & 14 deletions packages/components/table/EditableCell.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import React, { useEffect, useMemo, useRef, useState, MouseEvent } from 'react';
import { get, set, isFunction, cloneDeep } from 'lodash-es';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Edit1Icon as TdEdit1Icon } from 'tdesign-icons-react';
import classNames from 'classnames';
import { cloneDeep, get, isFunction, set } from 'lodash-es';

import log from '@tdesign/common-js/log/index';
import {
TableRowData,
import { validate } from '../form/formModel';
import useConfig from '../hooks/useConfig';
import useGlobalIcon from '../hooks/useGlobalIcon';
import { renderCell } from './Cell';
import { TableClassName } from './hooks/useClassName';

import type { AllValidateResult } from '../form/type';
import type {
PrimaryTableCellParams,
PrimaryTableCol,
PrimaryTableRowEditContext,
PrimaryTableRowValidateContext,
TableRowData,
TdBaseTableProps,
PrimaryTableCellParams,
} from './type';
import useGlobalIcon from '../hooks/useGlobalIcon';
import { TableClassName } from './hooks/useClassName';
import { renderCell } from './Cell';
import { validate } from '../form/formModel';
import { AllValidateResult } from '../form/type';
import useConfig from '../hooks/useConfig';

export interface EditableCellProps {
row: TableRowData;
Expand Down Expand Up @@ -213,10 +215,11 @@ const EditableCell = (props: EditableCellProps) => {

const onEditChange = (val: any, ...args: any) => {
setEditValue(val);
const editedRow = getCurrentRow(props.row, props.col.colKey, val);
const params = {
...cellParams,
value: val,
editedRow: set({ ...props.row }, props.col.colKey, val),
editedRow,
};
props.onChange?.(params);
props.onRuleChange?.(params);
Expand All @@ -231,7 +234,7 @@ const EditableCell = (props: EditableCellProps) => {
{
value: val,
trigger: 'onChange',
newRowData: getCurrentRow(currentRow, col.colKey, val),
newRowData: editedRow,
rowIndex: props.rowIndex,
},
...args,
Expand Down Expand Up @@ -310,7 +313,7 @@ const EditableCell = (props: EditableCellProps) => {
return (
<div
className={classNames(tableBaseClass.cellEditable)}
onClick={(e: MouseEvent<HTMLDivElement>) => {
onClick={(e) => {
setIsEdit(true);
e.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
Expand Down
8 changes: 5 additions & 3 deletions packages/components/table/hooks/useFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React, { useEffect, useState } from 'react';
import { getColumnsResetValue } from '@tdesign/common-js/table/utils';
import { isFunction } from 'lodash-es';
import { getColumnsResetValue } from '@tdesign/common-js/table/utils';

import TButton from '../../button';
import useControlled from '../../hooks/useControlled';
import { useLocaleReceiver } from '../../locale/LocalReceiver';
import TableFilterController from '../FilterController';
import useClassName from './useClassName';

import type { PrimaryTableRef } from '../interface';
import type {
FilterValue,
Expand All @@ -13,7 +16,6 @@ import type {
TableRowData,
TdPrimaryTableProps,
} from '../type';
import useClassName from './useClassName';

function isFilterValueExist(value: any) {
const isArrayTrue = value instanceof Array && value.length;
Expand Down Expand Up @@ -123,7 +125,7 @@ export default function useFilter(
column?: PrimaryTableCol,
) {
setTFilterValue(filterValue, { col: column, trigger });
props.onChange?.({ filter: filterValue }, { trigger: 'filter' });
props.onChange?.({ filter: filterValue }, { trigger: 'filter', currentData: props.data });
// 重置表格滚动位置
requestAnimationFrame(() => {
primaryTableRef.current?.scrollToElement({
Expand Down
Loading