fix visual snap of side pane on startup#15553
Conversation
|
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of |
Review Summary by QodoFix visual snap of side pane on startup
WalkthroughsDescription• Hide side pane during divider position initialization to prevent visual snap • Apply divider position after stage is fully shown using Platform.runLater • Add listener to update divider position when main stage becomes visible • Update changelog to document the side pane snap fix Diagramflowchart LR
A["Side pane added to split"] -- "Hide split pane" --> B["Platform.runLater"]
B -- "Update divider position" --> C["Show split pane"]
D["Main stage showing"] -- "Listener triggered" --> E["Update divider position"]
File Changes1. jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java
|
Code Review by Qodo
|
| mainStage.showingProperty().addListener((obs, wasShowing, isShowing) -> { | ||
| if (isShowing) { | ||
| updateHorizontalDividerPosition(); | ||
| } | ||
| }); |
There was a problem hiding this comment.
2. Leaked divider subscriptions 🐞 Bug ☼ Reliability
initBindings() adds a mainStage.showingProperty listener that calls updateHorizontalDividerPosition(), but JabRefGUI.onShowing() already calls it; because updateHorizontalDividerPosition() overwrites horizontalDividerSubscription without unsubscribing the previous subscription, repeated window show cycles will leak listeners and duplicate preference updates.
Agent Prompt
### Issue description
`updateHorizontalDividerPosition()` installs an EasyBind listener each time it runs, but it does not unsubscribe any prior listener. This PR adds an additional call site (`mainStage.showingProperty` listener), while `JabRefGUI.onShowing()` already calls the method, so subscriptions can stack up across show/hide cycles.
### Issue Context
- `JabRefGUI.onShowing()` already calls `mainFrame.updateHorizontalDividerPosition()`.
- `updateHorizontalDividerPosition()` assigns `horizontalDividerSubscription = ...listenToValues(...)` without cleanup.
### Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java[311-320]
- jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java[411-418]
- jabgui/src/main/java/org/jabref/gui/JabRefGUI.java[357-361]
### Suggested fix approach
- Prefer a single invocation path (remove the newly-added `showingProperty` listener, since `JabRefGUI.onShowing()` already handles it), **or**
- Make `updateHorizontalDividerPosition()` idempotent by unsubscribing an existing `horizontalDividerSubscription` before creating a new one (and consider doing the same for vertical for consistency).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Hey, turns out it was just dead code that I forgot to remove from one try to another. Removed on the last commit!
|
Idk why these tests aren't passing. What should I do? |
|
We are looking into it, please be patient. Maybe something with our CI pipeline. |
|
@pgrigolli should be fine now. |
Nice, thanks! What was wrong? |
We had a faulty Windows-specific test which was fixed in one of the recent PRs. |
Review Summary by QodoFix side pane visual snap on startup
WalkthroughsDescription• Hide side pane during divider position initialization to prevent visual snap • Use Platform.runLater() to apply divider position after layout is ready • Show side pane only after correct position has been set • Updated CHANGELOG.md with fix description Diagramflowchart LR
A["Side pane added to split"] --> B["Hide horizontal split pane"]
B --> C["Schedule divider position update"]
C --> D["Apply correct divider position"]
D --> E["Show horizontal split pane"]
E --> F["Side pane displays at correct width"]
File Changes1. jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java
|
Code Review by Qodo
1. CHANGELOG.md adds blank line
|
|
Do not mark a PR as ready-for-review if changes are required. |
|
Review Summary by QodoFix side pane snap on startup by deferring position update
WalkthroughsDescription• Fixes visual snap of side pane on startup by hiding it during initialization • Applies divider position after layout is ready using Platform.runLater() • Prevents incorrect positioning before showing the pane to user • Updates changelog to document the fix Diagramflowchart LR
A["Side pane added to split"] -- "Hide split pane" --> B["Defer position update"]
B -- "Apply divider position" --> C["Show split pane"]
C -- "User sees correct position" --> D["No visual snap"]
File Changes1. jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java
|
Code Review by Qodo
1. CHANGELOG.md adds blank line
|
Related issues and pull requests
Closes #15394
PR Description
When JabRef starts, the side pane was briefly rendered in the wrong position
before snapping to the correct width previously set by the user. The root cause
was that updateHorizontalDividerPosition() was called before the layout was ready,
causing the divider position to not be applied correctly. This was fixed by hiding
the horizontal split pane while the divider position is being applied, and showing
it again only after the correct position has been set, preventing the snap from
being visible to the user.
Steps to test
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)Video of the changes working (on Windows 11, developer version)
https://github.com/user-attachments/assets/782147b0-ded8-4b13-ad5c-527f67f63211
I couldn't test it on MacOS, but I tested on Linux (Debian 12) and it wasn't happening there!
Since the issue was first addressed on Windows, it should work now!
Library Entry
