1
0
Fork 0
mirror of synced 2024-09-10 06:26:02 +12:00

Fix move column left and right not working

This commit is contained in:
Andrew Kingston 2024-06-24 15:28:26 +01:00
parent e0c38d7fbe
commit c4748d5cd6
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View file

@ -18,7 +18,7 @@
isReordering,
isResizing,
sort,
visibleColumns,
scrollableColumns,
dispatch,
subscribe,
config,
@ -51,7 +51,7 @@
$: sortedBy = column.name === $sort.column
$: canMoveLeft = orderable && idx > 0
$: canMoveRight = orderable && idx < $visibleColumns.length - 1
$: canMoveRight = orderable && idx < $scrollableColumns.length - 1
$: sortingLabels = getSortingLabels(column.schema?.type)
$: searchable = isColumnSearchable(column)
$: resetSearchValue(column.name)

View file

@ -226,10 +226,10 @@ export const createActions = context => {
const moveColumnLeft = async column => {
const $visibleColumns = get(visibleColumns)
const $columnLookupMap = get(columnLookupMap)
const sourceIdx = $columnLookupMap[column]
const sourceIdx = $columnLookupMap[column].__idx
await moveColumn({
sourceColumn: column,
targetColumn: $visibleColumns[sourceIdx - 2]?.name,
targetColumn: $visibleColumns[sourceIdx - 1]?.name,
})
}
@ -237,13 +237,14 @@ export const createActions = context => {
const moveColumnRight = async column => {
const $visibleColumns = get(visibleColumns)
const $columnLookupMap = get(columnLookupMap)
const sourceIdx = $columnLookupMap[column]
const sourceIdx = $columnLookupMap[column].__idx
if (sourceIdx === $visibleColumns.length - 1) {
return
}
await moveColumn({
sourceColumn: column,
targetColumn: $visibleColumns[sourceIdx + 1]?.name,
insertAfter: true,
})
}