Skip to content

Commit

Permalink
fix: improved cell retrieval information on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
lucafoscili committed Jul 2, 2024
1 parent 630821a commit 2561ecb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/ketchup/src/components/kup-data-table/kup-data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ export class KupDataTable {
if (!cell) {
this.#kupManager.debug.logMessage(
this,
"Couldn't find cell hovered to retrieve dropzone informations!",
"Couldn't find cell to retrieve drag informations!",
KupDebugCategory.WARNING
);
return;
Expand Down Expand Up @@ -2161,26 +2161,22 @@ export class KupDataTable {
}
if (this.dropEnabled) {
const dataCb: KupDropDataTransferCallback = () => {
const cell =
this.rootElement.shadowRoot.querySelector('td:hover');
const cell = this.#lastPointerDetails?.cell;
const column = this.#lastPointerDetails?.column;
const row = this.#lastPointerDetails?.row;
if (!cell) {
this.#kupManager.debug.logMessage(
this,
"Couldn't find cell hovered to retrieve dropzone informations!",
"Couldn't find cell to retrieve dropzone informations!",
KupDebugCategory.WARNING
);
return;
}
const path = this.#kupManager.getEventPath(
cell,
this.rootElement
);
const receivingDetails = this.#getEventDetails(path);
return {
cell: receivingDetails.cell,
column: receivingDetails.column,
cell,
column,
id: this.rootElement.id,
row: receivingDetails.row,
row,
};
};
for (let index = 0; index < this.#rowsRefs.length; index++) {
Expand Down Expand Up @@ -5873,6 +5869,16 @@ export class KupDataTable {
e as unknown as Interact.PointerEvent
);
}}
onPointerUp={(e) => {
this.#lastPointerDetails =
this.#getEventDetails(
this.#kupManager.getEventPath(
e.target,
this.rootElement
),
e as unknown as Interact.PointerEvent
);
}}
onContextMenu={(e: MouseEvent) => {
e.preventDefault();
}}
Expand Down

0 comments on commit 2561ecb

Please sign in to comment.