Commit a22c4146 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '112-reordering-of-columns-isn-t-works-on-chrome-browser' into 'master'

Resolve "Reordering of columns isn`t works on Chrome browser"

Closes #112

See merge request grin-global/grin-global-ui!90
parents 20549a0d 8eb31510
......@@ -518,6 +518,10 @@ class Table extends React.Component<ITableProps & WithTranslation & WithStyles &
const columnKey = (e.currentTarget as HTMLElement).dataset.columnkey;
const droppedColumn = e.dataTransfer.getData('columnKey');
console.log(`Dropped column: ${droppedColumn}, target column: ${columnKey}`);
if (droppedColumn === columnKey || !droppedColumn) {
console.log(`prevent drop column ${droppedColumn}`);
return;
}
if (onColumnChange) {
onColumnChange(droppedColumn, { position: columns.indexOf(columnKey) });
}
......@@ -526,7 +530,7 @@ class Table extends React.Component<ITableProps & WithTranslation & WithStyles &
private allowDrop = (e: React.DragEvent<HTMLTableDataCellElement>) => {
const columnKey = (e.currentTarget as HTMLElement).dataset.columnkey;
const draggedColumn = e.dataTransfer.getData('columnKey');
if (draggedColumn === columnKey || !draggedColumn) { // also prevents passing non-columns to handleDrop
if (draggedColumn === columnKey) {
console.log(`prevent drop column ${draggedColumn}`);
return;
}
......
......@@ -135,7 +135,7 @@ const withUserSettings = <P extends ITableProps>(Component: React.ComponentType<
console.log(`Position of ${columnKey} set from ${currentPosition} to ${columnPosition}`);
if (currentPosition !== columnPosition) {
columns.splice(currentPosition, 1);
columns.splice(columnPosition > currentPosition ? columnPosition - 1 : columnPosition, 0, columnKey);
columns.splice(columnPosition, 0, columnKey);
_.forIn(columnSettings, (colConf, key) => {
if (colConf.position !== undefined) {
columnSettings = update(columnSettings, { [key]: { position: { $set: columns.indexOf(key) } } });
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment