Skip to content

Commit

Permalink
Merge pull request #715 from VisActor/712-bug-edit-blankCell-pivotTable
Browse files Browse the repository at this point in the history
712 bug edit blank cell pivot table
  • Loading branch information
fangsmile authored Dec 13, 2023
2 parents 2ff6ee4 + db2746d commit 01433c3
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: blank cell edit invalid on pivottbale #712\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
4 changes: 4 additions & 0 deletions packages/vtable/src/PivotTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,10 @@ export class PivotTable extends BaseTable implements PivotTableAPI {
}
this.eventManager.updateEventBinder();
}
/** 结束编辑 */
completeEditCell() {
this.editorManager.completeEdit();
}
/** 获取单元格对应的编辑器 */
getEditor(col: number, row: number) {
const define = this.getBodyColumnDefine(col, row);
Expand Down
18 changes: 18 additions & 0 deletions packages/vtable/src/dataset/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,24 @@ export class Dataset {
// return changeValue;
// };
}
return {
value() {
return changeValue;
},
className: '',
push() {
// do nothing
},
formatValue() {
return changeValue;
},
clearCacheValue() {
// do nothing
},
reset() {
// do nothing
}
};
}

// }
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/src/event/listener/container-dom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isValid } from '@visactor/vutils';
import type { EventHandler } from '../EventHandler';
import type { KeydownEvent } from '../../ts-types';
import type { KeydownEvent, ListTableAPI } from '../../ts-types';
import { TABLE_EVENT_TYPE } from '../../core/TABLE_EVENT_TYPE';
import { handleWhell } from '../scroll';
import { browser } from '../../tools/helper';
Expand Down
10 changes: 9 additions & 1 deletion packages/vtable/src/event/listener/table-group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { IEventTarget } from '@visactor/vrender';
import { Gesture, type FederatedPointerEvent } from '@visactor/vrender';
import type { MousePointerCellEvent, MousePointerMultiCellEvent, MousePointerSparklineEvent } from '../../ts-types';
import type {
ListTableAPI,
MousePointerCellEvent,
MousePointerMultiCellEvent,
MousePointerSparklineEvent
} from '../../ts-types';
import { InteractionState } from '../../ts-types';
import type { SceneEvent } from '../util';
import { getCellEventArgsSet } from '../util';
Expand Down Expand Up @@ -320,6 +325,9 @@ export function bindTableGroupListener(eventManager: EventManager) {
}
}
}
if ((table as ListTableAPI).editorManager) {
(table as ListTableAPI).editorManager.completeEdit();
}
stateManager.updateInteractionState(InteractionState.default);
eventManager.dealTableHover();
//点击到表格外部不需要取消选中状态
Expand Down
16 changes: 16 additions & 0 deletions packages/vtable/src/scenegraph/group-creater/cell-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,23 @@ export function updateCell(col: number, row: number, table: BaseTableAPI, addNew
dx: hierarchyOffset,
x
};
const oldText = textMark.attribute.text;
textMark.setAttributes(cellTheme.text ? (Object.assign({}, cellTheme.text, attribute) as any) : attribute);
if (!oldText && textMark.attribute.text) {
const textBaseline = cellTheme.text.textBaseline;
const height = cellHeight - (padding[0] + padding[2]);
let y = 0;
if (textBaseline === 'middle') {
y = padding[0] + (height - textMark.AABBBounds.height()) / 2;
} else if (textBaseline === 'bottom') {
y = padding[0] + height - textMark.AABBBounds.height();
} else {
y = padding[0];
}
textMark.setAttributes({
y
});
}
}
return oldCellGroup;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/vtable/src/ts-types/table-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { ICellAxisOption, ITableAxisOption } from './component/axis';
import type { IEditor } from '@visactor/vtable-editors';
import type { ITextStyleOption } from '../body-helper/style';
import type { DataSource } from '../data';
import type { EditManeger } from '../edit/edit-manager';

export interface CellAddress {
col: number;
Expand Down Expand Up @@ -157,6 +158,7 @@ export interface ListTableConstructorOptions extends BaseTableConstructorOptions

export interface ListTableAPI extends BaseTableAPI {
options: ListTableConstructorOptions;
editorManager: EditManeger;
sortState: SortState[] | SortState | null;
// internalProps: ListTableProtected;
isListTable: () => true;
Expand Down Expand Up @@ -309,6 +311,7 @@ export interface PivotChartConstructorOptions extends BaseTableConstructorOption
export interface PivotTableAPI extends BaseTableAPI {
records?: any;
options: PivotTableConstructorOptions;
editorManager: EditManeger;
// internalProps: PivotTableProtected;
pivotSortState: PivotSortState[];
isListTable: () => false;
Expand Down

0 comments on commit 01433c3

Please sign in to comment.