Skip to content

Commit 9baa03a

Browse files
fix: generator column item click
1 parent 75e3ac6 commit 9baa03a

File tree

3 files changed

+12
-6
lines changed
  • packages/drip-table-generator/src/layouts

3 files changed

+12
-6
lines changed

packages/drip-table-generator/src/layouts/attributes-layout/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ export const updateColumnItemByPath = (
3838

3939
export const getColumnItemByPath = (column: DTGTableConfig['columns'][number], path: (number | 'popover' | 'content')[]) => {
4040
const [key, ...rest] = path;
41-
if (!column || path.length <= 0) {
41+
if (!column) {
4242
return null;
4343
}
44+
if (column && path.length <= 0) {
45+
return column;
46+
}
4447
const newColumn = cloneDeep(column && 'schema' in column ? column.schema : column) as DTGTableConfig['columns'][number];
4548
if (newColumn.component === 'group') {
4649
const items = newColumn.options.items as DTGTableConfig['columns'] || [];

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/cell/group.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function GroupCell<
116116
onClick={(e) => {
117117
e.stopPropagation();
118118
setState({
119-
currentComponentPath: colChecked ? [] : [componentIndex],
119+
currentComponentPath: colChecked ? [] : [...props.path, componentIndex],
120120
currentComponentID: colChecked ? void 0 : itemColumnSchema?.key,
121121
currentColumnID: rootColumn.key,
122122
currentTableID: props.tableConfig.tableId,
@@ -137,10 +137,11 @@ function GroupCell<
137137
drawerType: 'column-item',
138138
});
139139
props.onClick?.('column-item', {
140-
currentComponentPath: colChecked ? [] : [componentIndex],
141-
currentComponentID: colChecked ? void 0 : itemColumnSchema?.key,
140+
currentComponentPath: [componentIndex],
141+
currentComponentID: itemColumnSchema?.key,
142142
currentColumnID: rootColumn.key,
143143
currentTableID: props.tableConfig.tableId,
144+
tableConfig: props.tableConfig,
144145
});
145146
}}
146147
/>

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/cell/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import React from 'react';
1616

1717
import { GeneratorContext } from '@/context';
1818
import { DTGTableConfig, TableConfigsContext } from '@/context/table-configs';
19-
import { updateColumnItemByPath } from '@/layouts/attributes-layout/utils';
19+
import { getColumnItemByPath, updateColumnItemByPath } from '@/layouts/attributes-layout/utils';
2020
import { getSchemaValue } from '@/layouts/utils';
2121
import { DataSourceTypeAbbr, DripTableGeneratorProps } from '@/typing';
2222

@@ -111,7 +111,9 @@ ExtraOptions extends Partial<DripTableExtraOptions> = never,
111111
onAddColumnItem={onAddColumnItem}
112112
onRemoveColumnItem={onRemoveColumnItem}
113113
onClick={(type, payload) => {
114-
if (type !== 'column-item') {
114+
const colPath = payload.currentComponentPath as (number | 'popover' | 'content')[] ?? [];
115+
const containerComponent = getColumnItemByPath(props.column, colPath);
116+
if (!(type === 'column-item' && containerComponent.component === 'group')) {
115117
setState({
116118
...payload,
117119
currentColumnID: props.column.key,

0 commit comments

Comments
 (0)