Skip to content

Commit 26b4fa4

Browse files
SiedlerchrSiva-Sai22
authored andcommitted
Fix dnd reordering in linked files (JabRef#14627)
* Fix dnd reordering in linked files Follow up from JabRef#12871 * changelog
1 parent d2301bd commit 26b4fa4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
5757
- We fixed localization of the "New Entries" dialog. [#14455](https://github.com/JabRef/jabref/pull/14455)
5858
- We fixed an issue where keybindings could not be edited and saved. [#14237](https://github.com/JabRef/jabref/issues/14237)
5959
- We readded the missing gui commands for importing and exporting preferences. [#14492](https://github.com/JabRef/jabref/pull/14492)
60+
- We fixed an issue where reordering linked files via drag and drop was no longer possible [14627](https://github.com/JabRef/jabref/pull/14627)
6061

6162
### Removed
6263

jabgui/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import javafx.beans.value.ObservableValue;
1010
import javafx.css.PseudoClass;
11+
import javafx.event.Event;
1112
import javafx.scene.Node;
1213
import javafx.scene.control.ComboBox;
1314
import javafx.scene.control.ContextMenu;
@@ -193,9 +194,16 @@ protected void updateItem(T item, boolean empty) {
193194
}
194195
if (toOnDragDropped != null) {
195196
setOnDragDropped(event -> {
196-
// The parent is the box for dropping; that should be used as target (and not this cell)
197+
// For reordering we need to accept the event so that the local handlers get it
198+
toOnDragDropped.accept(viewModel, event);
199+
Node parent = getParent();
200+
if (parent != null) {
201+
// The parent is the box for dropping from external files; that should be used as target (and not this cell)
202+
// We need to send a copy of the event before consuming the original one
203+
DragEvent forwarded = event.copyFor(parent, parent);
204+
Event.fireEvent(parent, forwarded);
205+
}
197206
event.consume();
198-
getParent().fireEvent(event);
199207
});
200208
}
201209
if (toOnDragEntered != null) {
@@ -206,8 +214,14 @@ protected void updateItem(T item, boolean empty) {
206214
}
207215
if (toOnDragOver != null) {
208216
setOnDragOver(event -> {
209-
event.consume(); // Prevent cells from acting as drop targets
210-
getParent().fireEvent(event); // The action performed was not look at the parent, the drop box
217+
// For reordering we need to accept the event so that the local handlers get it
218+
toOnDragOver.accept(viewModel, event);
219+
Node parent = getParent();
220+
if (parent != null) {
221+
DragEvent forwarded = event.copyFor(parent, parent);
222+
Event.fireEvent(parent, forwarded);
223+
}
224+
event.consume();
211225
});
212226
}
213227
for (Map.Entry<PseudoClass, Callback<T, ObservableValue<Boolean>>> pseudoClassWithCondition : pseudoClasses.entrySet()) {

0 commit comments

Comments
 (0)