Skip to content

Commit

Permalink
Click on entry at "Check integrity" focus bug fixed (#12022)
Browse files Browse the repository at this point in the history
* Two lines added: comment and the getScene().getWindow().requestFocus(); to make sure that focus goes to the field even when dialog window is opened

* Focus bug added to the Changelog's Fix field

* setFocusToField() fixed focus for JournalTitle Field

* Checkstyle Applied

* Added line in setFocusToField() to force opening every tab before selecting one
  • Loading branch information
mulla028 authored Nov 29, 2024
1 parent 04c0df9 commit 37593bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where trying to open a library from a failed mounted directory on Mac would cause an error. [#10548](https://github.com/JabRef/jabref/issues/10548)
- We fixed an issue when the preview was out of sync. [#9172](https://github.com/JabRef/jabref/issues/9172)
- We fixed an issue where identifier paste couldn't work with Unicode REPLACEMENT CHARACTER. [#11986](https://github.com/JabRef/jabref/issues/11986)
- We fixed an issue when click on entry at "Check Integrity" wasn't properly focusing the entry and field. [#11997](https://github.com/JabRef/jabref/issues/11997)

### Removed

Expand Down
21 changes: 19 additions & 2 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.SortedSet;
import java.util.stream.Collectors;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.geometry.Side;
import javafx.scene.control.Button;
Expand Down Expand Up @@ -61,6 +62,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.EntryConverter;
import org.jabref.model.entry.field.Field;
import org.jabref.model.util.DirectoryMonitorManager;
import org.jabref.model.util.FileUpdateMonitor;
Expand Down Expand Up @@ -463,11 +465,26 @@ private void fetchAndMerge(EntryBasedFetcher fetcher) {

public void setFocusToField(Field field) {
UiTaskExecutor.runInJavaFXThread(() -> {
Field actualField = field;
boolean fieldFound = false;
for (Tab tab : tabbed.getTabs()) {
tabbed.getSelectionModel().select(tab);
if ((tab instanceof FieldsEditorTab fieldsEditorTab)
&& fieldsEditorTab.getShownFields().contains(field)) {
&& fieldsEditorTab.getShownFields().contains(actualField)) {
tabbed.getSelectionModel().select(tab);
fieldsEditorTab.requestFocus(field);
Platform.runLater(() -> {
fieldsEditorTab.requestFocus(actualField);
});
// This line explicitly brings focus back to the main window containing the Entry Editor.
getScene().getWindow().requestFocus();
fieldFound = true;
break;
}
}
if (!fieldFound) {
Field aliasField = EntryConverter.FIELD_ALIASES.get(field);
if (aliasField != null) {
setFocusToField(aliasField);
}
}
});
Expand Down

0 comments on commit 37593bf

Please sign in to comment.