mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
fix(views/board): drop indicator remaining stuck
This commit is contained in:
parent
d98be19c9a
commit
545b19f978
@ -56,6 +56,9 @@ export class DifferentialBoardRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async performUpdate(): Promise<void> {
|
private async performUpdate(): Promise<void> {
|
||||||
|
// Clean up any stray drag indicators before updating
|
||||||
|
this.dragHandler.cleanup();
|
||||||
|
|
||||||
const currentState = this.getCurrentState();
|
const currentState = this.getCurrentState();
|
||||||
|
|
||||||
if (!this.lastState) {
|
if (!this.lastState) {
|
||||||
|
@ -39,6 +39,22 @@ export class BoardDragHandler {
|
|||||||
this.api = newApi;
|
this.api = newApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private cleanupAllDropIndicators() {
|
||||||
|
// Remove all drop indicators from the DOM to prevent layout issues
|
||||||
|
this.$container.find(".board-drop-indicator").remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
private cleanupColumnDropIndicators($columnEl: JQuery<HTMLElement>) {
|
||||||
|
// Remove drop indicators from a specific column
|
||||||
|
$columnEl.find(".board-drop-indicator").remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public method to clean up any stray indicators - can be called externally
|
||||||
|
cleanup() {
|
||||||
|
this.cleanupAllDropIndicators();
|
||||||
|
this.$container.find('.board-column').removeClass('drag-over');
|
||||||
|
}
|
||||||
|
|
||||||
private setupMouseDrag($noteEl: JQuery<HTMLElement>, note: any, branch: any) {
|
private setupMouseDrag($noteEl: JQuery<HTMLElement>, note: any, branch: any) {
|
||||||
$noteEl.on("dragstart", (e) => {
|
$noteEl.on("dragstart", (e) => {
|
||||||
this.context.draggedNote = note;
|
this.context.draggedNote = note;
|
||||||
@ -60,8 +76,8 @@ export class BoardDragHandler {
|
|||||||
this.context.draggedBranch = null;
|
this.context.draggedBranch = null;
|
||||||
this.context.draggedNoteElement = null;
|
this.context.draggedNoteElement = null;
|
||||||
|
|
||||||
// Remove all drop indicators
|
// Clean up all drop indicators properly
|
||||||
this.$container.find(".board-drop-indicator").removeClass("show");
|
this.cleanupAllDropIndicators();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +136,7 @@ export class BoardDragHandler {
|
|||||||
} else {
|
} else {
|
||||||
// Remove all drag indicators if not over a column
|
// Remove all drag indicators if not over a column
|
||||||
this.$container.find('.board-column').removeClass('drag-over');
|
this.$container.find('.board-column').removeClass('drag-over');
|
||||||
this.$container.find(".board-drop-indicator").removeClass("show");
|
this.cleanupAllDropIndicators();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +163,7 @@ export class BoardDragHandler {
|
|||||||
this.context.draggedBranch = null;
|
this.context.draggedBranch = null;
|
||||||
this.context.draggedNoteElement = null;
|
this.context.draggedNoteElement = null;
|
||||||
this.$container.find('.board-column').removeClass('drag-over');
|
this.$container.find('.board-column').removeClass('drag-over');
|
||||||
this.$container.find(".board-drop-indicator").removeClass("show");
|
this.cleanupAllDropIndicators();
|
||||||
|
|
||||||
// Remove drag preview
|
// Remove drag preview
|
||||||
if ($dragPreview) {
|
if ($dragPreview) {
|
||||||
@ -182,7 +198,7 @@ export class BoardDragHandler {
|
|||||||
|
|
||||||
if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) {
|
if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) {
|
||||||
$columnEl.removeClass("drag-over");
|
$columnEl.removeClass("drag-over");
|
||||||
$columnEl.find(".board-drop-indicator").removeClass("show");
|
this.cleanupColumnDropIndicators($columnEl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -228,12 +244,11 @@ export class BoardDragHandler {
|
|||||||
const columnRect = $columnEl[0].getBoundingClientRect();
|
const columnRect = $columnEl[0].getBoundingClientRect();
|
||||||
const relativeY = y - columnRect.top;
|
const relativeY = y - columnRect.top;
|
||||||
|
|
||||||
// Find existing drop indicator or create one
|
// Clean up any existing drop indicators in this column first
|
||||||
let $dropIndicator = $columnEl.find(".board-drop-indicator");
|
this.cleanupColumnDropIndicators($columnEl);
|
||||||
if ($dropIndicator.length === 0) {
|
|
||||||
$dropIndicator = $("<div>").addClass("board-drop-indicator");
|
// Create a new drop indicator
|
||||||
$columnEl.append($dropIndicator);
|
const $dropIndicator = $("<div>").addClass("board-drop-indicator");
|
||||||
}
|
|
||||||
|
|
||||||
// Find the best position to insert the note
|
// Find the best position to insert the note
|
||||||
const $notes = this.context.draggedNoteElement ?
|
const $notes = this.context.draggedNoteElement ?
|
||||||
@ -316,6 +331,9 @@ export class BoardDragHandler {
|
|||||||
await this.onBoardRefresh();
|
await this.onBoardRefresh();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update note position:", error);
|
console.error("Failed to update note position:", error);
|
||||||
|
} finally {
|
||||||
|
// Always clean up drop indicators after drop operation
|
||||||
|
this.cleanupAllDropIndicators();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user