Skip to content

Commit

Permalink
Introduce clearDragHover method for centralized drag hover state re…
Browse files Browse the repository at this point in the history
…setting

Clears `hoverIndex` on drag exit events and `onLoadDocumentsRequest` that occurs after drag dropped events. Previously, the drag hover resetting was only happening after the drag dropped events. This change ensures that even when a drag drop doesn't occur after a drag entry, the drag-hover pseudo gets reset.
  • Loading branch information
IdelsTak committed Dec 15, 2023
1 parent 472f185 commit 00d2b65
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ private Consumer<DragEvent> onDragEnteredConsumer() {
}

private void onDragExited(DragEvent e) {
clearDragHover();
placeHolder.setDisable(true);
e.consume();
}
Expand Down Expand Up @@ -421,7 +422,7 @@ public void onLoadDocumentsRequest(PdfLoadRequest loadEvent) {
getSortOrder().clear();
getItems().addAll(dropIndex, toDrop);
focus.map(getItems()::indexOf).ifPresent(getFocusModel()::focus);
hoverIndex.setValue(-1);
clearDragHover();
this.sort();

loadEvent.getDocuments().stream().findFirst().ifPresent(
Expand Down Expand Up @@ -558,4 +559,8 @@ private int calculateHoverIndex(DragEvent event) {

return -1;
}

private void clearDragHover() {
hoverIndex.setValue(-1);
}
}

0 comments on commit 00d2b65

Please sign in to comment.