Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c4db0b1
BitEntryClass created
Mbungai-Francesco Nov 4, 2025
5dd02dd
resolution issue v1
Nov 26, 2025
48ee9d5
retrait de ligne de code inutile
Nov 26, 2025
8d33da7
retrait de ligne de code inutile
Nov 26, 2025
52c0f05
Merge branch 'JabRef:main' into fix-for-issue-12351
UserEstrella Nov 27, 2025
4459622
keMerge branch 'fix-for-issue-12351' of https://github.com/paulamalva…
paulamalvarador-commits Nov 27, 2025
696639a
change tooltipe size
paulamalvarador-commits Nov 27, 2025
5f2074d
Add changelog.md
paulamalvarador-commits Nov 27, 2025
a0f688d
Merge branch 'main' into fix-for-issue-12351
paulamalvarador-commits Nov 27, 2025
f2b66e7
second attempst pull request issue 2
paulamalvarador-commits Nov 27, 2025
4ad537b
Merge branch 'JabRef:main' into fix-for-issue-12351
samol123456 Nov 29, 2025
19a80ad
rmv line
Nov 29, 2025
4ab7398
rmv import
Nov 29, 2025
71cc5f2
rmv space2
Nov 29, 2025
083e413
rmv files
Nov 29, 2025
a5f412a
Fix submodules
Nov 30, 2025
58e073b
Merge branch 'JabRef:main' into fix-for-issue-12351
samol123456 Nov 30, 2025
7e52ab0
Merge branch 'main' into fix-for-issue-12351
samol123456 Nov 30, 2025
8fe53d8
Modification
Dec 1, 2025
ae2a21a
Modification
Dec 1, 2025
ad8c35c
fix checkstyle
Dec 1, 2025
dae4c68
Merge branch 'JabRef:main' into fix-for-issue-12351
UserEstrella Dec 1, 2025
5f9da86
fix indentation
Dec 1, 2025
1e220f0
Merge branch 'fix-for-issue-12351' of https://github.com/paulamalvara…
Dec 1, 2025
59202f3
fix import order
Dec 1, 2025
d4aa3cb
Modification previewviewer
Dec 1, 2025
e3a824b
Modification previewviewer2
Dec 1, 2025
b20a978
fix OpenRewrite
Dec 1, 2025
7149bb1
remove unused var
Dec 1, 2025
eab90b3
Merge branch 'main' into fix-for-issue-12351
UserEstrella Dec 2, 2025
8ce5c92
adding comment et refactor some script
Dec 2, 2025
fd1290d
fix checkstyle
Dec 2, 2025
4c9de0e
fix emptyline
Dec 2, 2025
b1a3b5a
Modification des noms des variables et suppresion PreviewViewerRefect…
Dec 3, 2025
3619d1b
comment deletion
Dec 5, 2025
59c42ff
rename variale h and w
Dec 5, 2025
fe245ff
correction of previewWidthPadding
Dec 5, 2025
a8b02aa
list exceptions
Dec 5, 2025
ab4baee
remove blank
Dec 5, 2025
42a8e43
reformat code
Dec 5, 2025
d898c3b
remove java.scripting
Dec 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed the fallback window height (786 → 768) in JabRefGUI. [#14295](https://github.com/JabRef/jabref/pull/14295)
- We fixed localization of the "New Entries" dialog. [#14455](https://github.com/JabRef/jabref/pull/14455)
- We fixed an issue where keybindings could not be edited and saved. [#14237](https://github.com/JabRef/jabref/issues/14237)
- Fixed the entry-table tooltip appearing oversized when preview was enabled. The tooltip now adapts to its content. [#12351](https://github.com/JabRef/jabref/issues/12351)
- We readded the missing gui commands for importing and exporting preferences. [#14492](https://github.com/JabRef/jabref/pull/14492)

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;

public class MainTableTooltip extends Tooltip {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MainTableTooltip extends Tooltip {
private static final Logger LOGGER = LoggerFactory.getLogger(MainTableTooltip.class);
private final PreviewViewer preview;
private final GuiPreferences preferences;
private final VBox tooltipContent = new VBox();
Expand All @@ -22,11 +25,49 @@ public class MainTableTooltip extends Tooltip {
public MainTableTooltip(DialogService dialogService, GuiPreferences preferences, ThemeManager themeManager, TaskExecutor taskExecutor) {
this.preferences = preferences;
this.preview = new PreviewViewer(dialogService, preferences, themeManager, taskExecutor);
this.tooltipContent.getChildren().addAll(fieldValueLabel, preview);

fieldValueLabel.setWrapText(true);
fieldValueLabel.setMaxWidth(Double.MAX_VALUE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why MAX_VALUE?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also noticed this flickering issue on hover. However, it does not come from our pull request: the same behavior is already present in the official version currently available for download.

video.mp4

Using Double.MAX_VALUE here is intentional. In a VBox, a Node expands to its
maximum width only if its maxWidth is large enough. By setting it to
Double.MAX_VALUE, we let JavaFX resize the label and the tooltip to the width
determined by the preview calculation and the layout, instead of forcing a fixed
max width. This avoids clipping long text values and ensures the tooltip adapts
to the content.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this connected to the flickering issue? Can you clarify a bit more

Copy link
Author

@samol123456 samol123456 Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not connected i just give the answer to this question:
Why MAX_VALUE?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your answer starts with "We also noticed this flickering issue". Therefore Subhramit wondered...

grafik

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also noticed this flickering issue on hover. However, it does not come from our pull request: the same behavior is already present in the official version currently available for download.

I cannot reproduce the situation again.

However, the popup is placed too far away when jumping:

image
Video.mp4


tooltipContent.getChildren().addAll(fieldValueLabel, preview);
tooltipContent.setSpacing(5);

this.setMaxWidth(500);
this.setWrapText(true);

final double PREVIEW_WIDTH_PADDING = 16.0;
final double PREVIEW_HEIGHT_PADDING = 8.0; // Padding to avoid bottom clipping of the preview
final double MIN_TOOLTIP_WIDTH = 200.0; // Minimum width of the tooltip to keep layout stable even with small content

preview.contentHeightProperty().addListener((_, _, val) -> {
double contentHeight = val == null ? 0 : val.doubleValue();
if (contentHeight <= 0) {
LOGGER.debug("contentHeightProperty emitted non-positive value: {}", contentHeight);
return;
}

preview.setPrefHeight(contentHeight + PREVIEW_HEIGHT_PADDING);
});

preview.contentWidthProperty().addListener((_, _, val) -> {
double contentWidth = val == null ? 0 : val.doubleValue();
if (contentWidth <= 0) {
LOGGER.debug("contentWidthProperty emitted non-positive value: {}", contentWidth);
return;
}

double desired = Math.max(contentWidth + PREVIEW_WIDTH_PADDING, MIN_TOOLTIP_WIDTH);

// We set a very large max width so that JavaFX does not artificially clamp the tooltip.
// The effective width is still limited by the window and screen bounds.
this.setMaxWidth(Double.MAX_VALUE);
this.setPrefWidth(desired);
});
}

public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, String fieldValue) {
fieldValueLabel.setText(fieldValue + "\n");
fieldValueLabel.setText(fieldValue);

if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) {
preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout());
preview.setDatabaseContext(databaseContext);
Expand Down
60 changes: 58 additions & 2 deletions jabgui/src/main/java/org/jabref/gui/preview/PreviewViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import java.net.MalformedURLException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.concurrent.Worker;
Expand Down Expand Up @@ -85,6 +88,8 @@ function getSelectionHtml() {
private @Nullable BibEntry entry;
private PreviewLayout layout;
private String layoutText;
private final ReadOnlyDoubleWrapper contentHeight = new ReadOnlyDoubleWrapper(0);
private final ReadOnlyDoubleWrapper contentWidth = new ReadOnlyDoubleWrapper(0);

public PreviewViewer(DialogService dialogService,
GuiPreferences preferences,
Expand All @@ -105,8 +110,11 @@ public PreviewViewer(DialogService dialogService,
this.searchQueryProperty = searchQueryProperty;
this.searchQueryProperty.addListener((_, _, _) -> highlightLayoutText());

setFitToHeight(true);
setFitToWidth(true);
setFitToHeight(false);
setFitToWidth(false);

setHbarPolicy(ScrollBarPolicy.NEVER);
setVbarPolicy(ScrollBarPolicy.NEVER);
previewView = WebViewStore.get();
setContent(previewView);

Expand Down Expand Up @@ -144,9 +152,57 @@ private void configurePreviewView(ThemeManager themeManager) {
evt.preventDefault();
}, false);
}

try {
Object heightObj = previewView.getEngine().executeScript("document.getElementById('content').scrollHeight || document.body.scrollHeight");
Object widthObj = previewView.getEngine().executeScript("document.getElementById('content').scrollWidth || document.body.scrollWidth");
Comment on lines +157 to +158
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but I think there should be a neater way to do this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What the comment means - where did you get the hint from? What alternatives did you consider?


Double height = null;
if (heightObj instanceof java.lang.Number heightNum) {
height = heightNum.doubleValue();
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No empty line here

Suggested change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Double width = null;
if (widthObj instanceof java.lang.Number widthNum) {
width = widthNum.doubleValue();
}

// Use a single runLater to update both properties at once. We store the
// measured values as Optionals to make the intent explicit.
Optional<Double> optHeight = Optional.ofNullable(height);
Optional<Double> optWidth = Optional.ofNullable(width);
Comment on lines +172 to +173
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is more readable in this case. - you should use optionals in the whole method - and not switch from null to Optionals. -- Using null is OK as altternative. But do not mix.


javafx.application.Platform.runLater(() -> {
optHeight.ifPresent(measuredHeight -> {
contentHeight.set(measuredHeight);
// small padding so the rendered content is not clipped at edges
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment is off by one line.

Use "speaking" variable names: height instead of h

this.setPrefHeight(measuredHeight + 8);
});
optWidth.ifPresent(measuredWidth -> {
contentWidth.set(measuredWidth);
this.setPrefWidth(measuredWidth + 8);
});
});

setHvalue(0);
} catch (NullPointerException e) {
LOGGER.debug("Null value encountered while computing preview content size", e);
} catch (ClassCastException e) {
LOGGER.debug("Unexpected type returned from JavaScript while computing preview content size", e);
} catch (IllegalStateException e) {
LOGGER.debug("JavaFX thread not ready while computing preview content size", e);
}
});
}

public ReadOnlyDoubleProperty contentHeightProperty() {
return contentHeight.getReadOnlyProperty();
}

public ReadOnlyDoubleProperty contentWidthProperty() {
return contentWidth.getReadOnlyProperty();
}

public void setLayout(PreviewLayout newLayout) {
// Change listeners might set the layout to null while the update method is executing, therefore, we need to prevent this here
if ((newLayout == null) || newLayout.equals(layout)) {
Expand Down