-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Area of preview on hover should be shrink to the size of the text displayed #14478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Area of preview on hover should be shrink to the size of the text displayed #14478
Conversation
…rador-commits/jabref into fix-for-issue-12351
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Okay we are going to fix it |
| Object heightObj = previewView.getEngine().executeScript("document.getElementById('content').scrollHeight || document.body.scrollHeight"); | ||
| Object widthObj = previewView.getEngine().executeScript("document.getElementById('content').scrollWidth || document.body.scrollWidth"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
| /** | ||
| * 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()); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
|
@samol123456 Please use English words for commit messages (in future) |
| /** | ||
| * Expose the measured content height of the rendered preview. Value is in CSS pixels. | ||
| */ |
There was a problem hiding this comment.
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.
| /** | ||
| * Expose the measured content width of the rendered preview. Value is in CSS pixels. | ||
| */ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
| Optional<Double> optHeight = Optional.ofNullable(height); | ||
| Optional<Double> optWidth = Optional.ofNullable(width); |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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?
| this.setPrefHeight(h + 8); | ||
| }); | ||
| optWidth.ifPresent(w -> { | ||
| contentWidth.set(w); | ||
| this.setPrefWidth(w + 8); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
| // requires mslinks; | ||
| requires org.antlr.antlr4.runtime; | ||
| requires org.libreoffice.uno; | ||
| requires java.scripting; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?



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.
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)