Skip to content

Conversation

@samol123456
Copy link

@samol123456 samol123456 commented Nov 30, 2025

Closes #12351

This PR improves the sizing behavior of the entry-table tooltip when the preview feature is enabled.
Previously, the tooltip became significantly larger than the actual preview content due to missing layout constraints.
The fix adjusts the tooltip container and the PreviewViewer sizing logic so the tooltip now adapts to its preferred size and remains compact.

Steps to test

Open Preferences → Entry preview.

Enable: “Show preview in entry table tooltip”.

Hover over any entry in the main table.

Observe that the tooltip now:

matches the size of the preview content,

no longer grows excessively,

remains readable and compact.

image

Mandatory checks

@github-actions
Copy link
Contributor

Hey @samol123456!

Thank you for contributing to JabRef! Your help is truly appreciated ❤️

We have automated checks in place, based on which you will soon get feedback if any of them are failing. In a while, maintainers will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs.

Please re-check our contribution guide in case of any other doubts related to our contribution workflow.

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 30, 2025
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Does not work with Chocolate.bib

grafik

Scrollbar appears at longer entry previews:

grafik

@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Nov 30, 2025
@samol123456
Copy link
Author

Okay we are going to fix it

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 2, 2025
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 2, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 2, 2025
Comment on lines +157 to +158
Object heightObj = previewView.getEngine().executeScript("document.getElementById('content').scrollHeight || document.body.scrollHeight");
Object widthObj = previewView.getEngine().executeScript("document.getElementById('content').scrollWidth || document.body.scrollWidth");
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?

Comment on lines 11 to 25
/**
* Lightweight tests that ensure the PreviewViewer exposes content size properties
* used by UI components for adaptive-sizing (reflections avoid needing a JavaFX runtime here).
*/
public class PreviewViewerReflectionTest {

@Test
public void contentPropertiesExist() throws Exception {
Class<?> clazz = PreviewViewer.class;

Method heightMethod = clazz.getMethod("contentHeightProperty");
assertEquals(ReadOnlyDoubleProperty.class, heightMethod.getReturnType());

Method widthMethod = clazz.getMethod("contentWidthProperty");
assertEquals(ReadOnlyDoubleProperty.class, widthMethod.getReturnType());
Copy link
Member

Choose a reason for hiding this comment

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

These tests are AI-generated and make no sense in context of the changed functionality

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 contentH = val == null ? 0 : val.doubleValue();
Copy link
Member

Choose a reason for hiding this comment

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

Use full variable names - contentHeight, contentWidth etc

@koppor
Copy link
Member

koppor commented Dec 3, 2025

@samol123456 Please use English words for commit messages (in future)

Comment on lines 194 to 196
/**
* Expose the measured content height of the rendered preview. Value is in CSS pixels.
*/
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that "measured" is right - remove the whole comment.

Comment on lines 201 to 203
/**
* Expose the measured content width of the rendered preview. Value is in CSS pixels.
*/
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that "measured" is right - remove the whole comment.


javafx.application.Platform.runLater(() -> {
optHeight.ifPresent(h -> {
// 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

Comment on lines +172 to +173
Optional<Double> optHeight = Optional.ofNullable(height);
Optional<Double> optWidth = Optional.ofNullable(width);
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.

@koppor koppor added the status: changes-required Pull requests that are not yet complete label Dec 4, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 5, 2025
Comment on lines 38 to 40
final double previewWidthPadding = 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
Copy link
Member

Choose a reason for hiding this comment

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

You do see that you case the final variables differently, don't you?

Comment on lines 179 to 183
this.setPrefHeight(h + 8);
});
optWidth.ifPresent(w -> {
contentWidth.set(w);
this.setPrefWidth(w + 8);
Copy link
Member

Choose a reason for hiding this comment

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

You do see that you did not use the constant from above?

});

setHvalue(0);
} catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

Please list the exceptions explicitely (JabRef style)

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 5, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 5, 2025
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 5, 2025
// requires mslinks;
requires org.antlr.antlr4.runtime;
requires org.libreoffice.uno;
requires java.scripting;
Copy link
Member

Choose a reason for hiding this comment

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

You do know what "alphabetically" means?

image

Copy link
Author

Choose a reason for hiding this comment

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

Yes,
But I did not touch this file

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/JabRef/jabref/pull/14478/files shows it.

I assume IntelliJ might have added it - maybe, you can just remove it?

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Area of preview on hover should be shrink to the size of the text displayed

6 participants