Skip to content

Conversation

@sergeyteleshev
Copy link
Contributor

@sergeyteleshev sergeyteleshev commented Oct 1, 2025

closes https://github.com/dbeaver/pro/issues/6859

Changes:

  1. Added pin/unpin logic
  2. Refactored the columnId logic. Now we have two types of IDs. Visual column id represents the column number on the screen. And dataColIdx, which means the column index in the initial columns array provided to the data grid
  3. Some features need to use visual column ID, some need to use dataColIdx. So used it respectively where required
  4. Removed weird cell focus hack cause everything works fine without it

@sergeyteleshev sergeyteleshev self-assigned this Oct 1, 2025
@sergeyteleshev sergeyteleshev marked this pull request as ready for review October 9, 2025 09:00
focusSyncRef.current = { colIdx, rowIdx };

this.selectCell({ colIdx, rowIdx });
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in use anywhere. Only in the deleted piece below, so I removed it also

const [dragOverElement, setDragOverElement] = useState<[number, boolean] | null>(null);

function getDataColIdxByKey(key: string) {
const columnIndex = columns.filter(isColumn).findIndex(col => col.key === key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const columnIndex = columns.filter(isColumn).findIndex(col => col.key === key);
const columnIndex = columns.findIndex(col => isColumn(col) && col.key === key);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway this part probably will be changed if we will start using column groups

model: IDatabaseDataModel;
actions: IDataTableActions;
spreadsheetActions: IDataPresentationActions<IGridDataKey>;
spreadsheetActions: IDataPresentationActions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert

edit: (key: TKey) => void;
import type { IGridColumnKey, IGridDataKey } from '../DatabaseDataModel/Actions/Grid/IGridDataKey.js';

export interface IDataPresentationActions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep generics

Comment on lines -106 to +107
const columns = new Array<ColumnOrColumnGroup<IInnerRow, unknown>>(columnsCount)
.fill(null as any)
.map((_, i): ColumnOrColumnGroup<IInnerRow, unknown> => {
const width = getHeaderWidth?.(i) ?? 'max-content';
return {
key: getColumnKey?.(i) ?? String(i),
name: '',
resizable: getHeaderResizable?.(i) ?? true,
width,
minWidth: 26,
editable: row => getCellEditable?.(row.idx, i) ?? false,
frozen: getHeaderPinned?.(i),
renderHeaderCell: mapRenderHeaderCell(i),
renderCell: mapCellContentRenderer(i),
renderEditCell: mapEditCellRenderer(i),
};
});
const columns = new Array<ColumnOrColumnGroup<IInnerRow, unknown>>(columnsCount).fill(null as any).map((_, i) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert

Comment on lines +119 to +120
renderEditCell: mapEditCellRenderer(i),
} as Column<IInnerRow, unknown>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert

Comment on lines +287 to +289
pinColumn,
unpinColumn,
isColumnPinned,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will suggest using a different context for pinned columns, because right now every pin will trigger the rerender of all subscribers of the IDataGridContext

import { createAction } from '@cloudbeaver/core-view';

export const ACTION_DATA_GRID_PIN_COLUMN = createAction('data-grid-pin-column', {
label: 'data_grid_table_pin_column',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use proper localization key started with plugin's name as prefix: plugin_data_spreadsheet_new_

Comment on lines +111 to +117
if (action === ACTION_DATA_GRID_PIN_COLUMN) {
return { ...action.info, label: 'data_grid_table_pin_column' };
}

if (action === ACTION_DATA_GRID_UNPIN_COLUMN) {
return { ...action.info, label: 'data_grid_table_unpin_column' };
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably you don't need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants