Skip to content

Reduce layout jump of tags editors - #17555

Merged
Siedlerchr merged 12 commits into
JabRef:mainfrom
NoureddineCH1:fix-for-issue-17229
Nov 6, 2026
Merged

Siedlerchr merged 12 commits into
JabRef:mainfrom
NoureddineCH1:fix-for-issue-17229

Conversation

@NoureddineCH1

@NoureddineCH1 NoureddineCH1 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The entry editor flickered when switching between entries that have a tags field (groups, keywords). While a TagsField has no width yet, GemsFX's FlowPane puts every tag on its own row, so TagsEditor first reported a height of about one row per tag (115 px for 4 tags) and then dropped to 27 px once the field got its width. A new editor is created on every entry change, so this jump happened on every click.

TagsEditor now reports the height of a single row (minimum and preferred height) until the TagsField has a width. For 4 tags, the initial height goes from 115 px to 22.5 px. A slight residual flicker remains; I could not identify its cause (ruled out: entry preview, scroll bar policy, initial placement of the tags).

This is a draft. Next step: find the cause of the residual flicker, and report the FlowPane behaviour to GemsFX.

Steps to test

  1. Open a library with entries that have a groups field with at least 4 comma-separated groups, for example groups = {a, b, c, d}.
  2. Open the entry editor, go to the "Main" tab and scroll to the "Meta" section.
  3. Select the entries one after the other in the main table.
  4. The lower part of the editor jumps much less than before (screenshot below). A slight residual flicker may remain.

Related issues and pull requests

Closes #17229

AI CHECKLIST.md walkthrough

1. Code self-review

Nullability and control flow

  • No == null / != null checks — JSpecify annotations (@NullMarked, @Nullable, @NonNull) used instead.
  • No Objects.requireNonNull(...) — nullability expressed via JSpecify annotations.
  • [/] New classes annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] New packages annotated with @NullMarked (org.jspecify.annotations.NullMarked).
  • [/] Optional consumed with ifPresent / ifPresentOrElse / map / orElseThrow — never orElse(unusedValue) nor an isPresent() + get() block.
  • [/] StringUtil.isBlank(...) used instead of s == null || s.isBlank().

Exceptions

  • No catch (Exception e) — only specific exceptions are caught.
  • No throw new RuntimeException(...) / IllegalStateException(...) — these tear down the whole application.
  • [/] Logged exceptions are passed as the last logger argument (LOGGER.info("...", e)), not concatenated into the message string.

Style and idioms

  • [/] New BibEntry objects built with withers (withField, not setField).
  • [/] Modern Java used: List.of() / Map.of() / Set.of(), Path.of(), SequencedCollection / SequencedSet, text blocks.
  • [/] Regexes use a precompiled Pattern.compile(...) constant, not String.matches(...).
  • [/] Keep alphabetical ordering when adding variables or enum items.
  • [/] Background work uses org.jabref.logic.util.BackgroundTask, not new Thread().
  • No commented-out code, no trivial comments restating the code, no AI-disclosure comments in source.
  • Markdown Javadoc (///) uses Markdown syntax, not JavaDoc inline tags: `code` instead of {@code}, [ClassName] instead of {@link}.

User-facing text

  • [/] All user-facing text localized (Localization.lang in Java, % prefix in FXML).
  • [/] Sentence case (not Title Case); no trailing !; labels do not end with :.
  • [/] Variance expressed with placeholders ("...: %0"), not string concatenation.

Security

  • [/] User-controlled data (request params, entry fields, file contents) is HTML-escaped before being written into any text/html response — including exception/error messages, not just the success body (XSS).

Tests

  • [/] In case issue lists an example, this concrete example is covered by a test case.
  • [/] Behavior changes in org.jabref.model / org.jabref.logic have added or updated tests.
  • [/] Tests assert object contents (assertEquals), use plain JUnit asserts (not AssertJ), have no @DisplayName, do not catch exceptions (let them propagate so JUnit reports setup/teardown failures directly), and use @TempDir instead of manual temp directories.
  • [/] Fetcher tests hit the live endpoints — the remote API is not mocked or stubbed (automated-review suggestions to mock it are rejected on purpose).

2. Verification commands

  • ./gradlew :jablib:check (or ./gradlew check for all modules).
  • ./gradlew checkstyleMain checkstyleTest checkstyleJmh.
  • ./gradlew modernizer.
  • ./gradlew --no-configuration-cache :rewriteDryRun reports no changes (run ./gradlew rewriteRun to fix).
  • ./gradlew javadoc.
  • npx markdownlint-cli2 "docs/**/*.md" "*.md" (only if Markdown changed).
  • npm ci && npm run textlint reports no misspellings (only if Markdown changed).
  • [/] Only if formatting is still off after rewriteRun: docker run -v $(pwd):/github/workspace ghcr.io/leventebajczi/intellij-format:master "*.java" "" ".idea/codeStyles/Project.xml".

3. Documentation

  • CHANGELOG.md entry added if the change is visible to the user (end-user wording, no extra blank lines, sorted in next to existing entries about the same component/feature). Link the issue if one exists; link the PR only when no issue exists. Use TODO as the placeholder when neither is known yet — never a fake number. No entry for fixes to changes that were themselves introduced after the last release (feature only in ## [Unreleased]) — update the existing unreleased entry instead if needed.
  • Searched jabref/issues and jabref-koppor/issues for a related issue; linked only on a confident match, otherwise kept TODO (no closes/fixes for merely-similar issues).
  • [/] Requirement added to docs/requirements/<area>.md if the change is a new feature or significant bug fix (skip for refactors, minor fixes, and internal changes).
  • [/] Developer documentation under docs/ updated if behavior or architecture changed.

4. Pull request

  • PR body built from .github/PULL_REQUEST_TEMPLATE.md, every section filled.
  • All checklist items kept and marked [x], [ ], or [/].
  • "Steps to test" is a numbered list with a cropped screenshot of the result for every visible change; no video (only allowed when another program is involved, e.g. drag and drop or push to an external application).
  • All HTML comments removed from the PR body.
  • PR created with gh pr create --body-file <file> (not --body).
  • [/] If CHANGELOG.md used a TODO placeholder (no issue confidently identified yet — an existing issue link always stays), the PR was opened as draft, the placeholder was replaced with the real PR-number link after PR creation, committed and pushed, and only then was the PR marked ready for review. If an issue is identified or created later, the link is switched to the issue.
Capture d'écran 2026-10-25 141207

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • If AI tools were used, I disclosed them in the "AI usage" section and reviewed, understood, and take full ownership of all AI-generated code
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • I added one sentence (max 20 words) to CHANGELOG.md describing the change from the user's point of view (if the change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@github-actions

Copy link
Copy Markdown
Contributor

Hey @NoureddineCH1! 👋

Thank you for contributing to JabRef!

We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request.

After all automated checks pass, a maintainer 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. You can read about the whole pull request process in our contribution guide.

Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures.

@jabref-machine jabref-machine added the dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) label Oct 23, 2026
@github-actions github-actions Bot mentioned this pull request Oct 23, 2026
2 tasks done
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Oct 23, 2026
@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Oct 25, 2026
@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Oct 27, 2026
@NoureddineCH1

Copy link
Copy Markdown
Contributor Author

The "Unit tests (Windows) (jablib)" job failed because embedded Postgres was not unpacked within 60 seconds (SqlBasedLibrarySearcherWithBibFilesTest). The JBang check also failed on a dependency download. My change only touches TagsEditor in jabgui, so these look unrelated. Could a maintainer re-run the failed jobs?

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: changes-required Pull requests that are not yet complete labels Oct 31, 2026
@Siedlerchr

Copy link
Copy Markdown
Member

I reran the tests now and see if it works now. Probably some github hiccup

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Oct 31, 2026
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Nov 3, 2026
@Siedlerchr
Siedlerchr marked this pull request as ready for review November 4, 2026 21:03
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Reduce entry editor layout jumps for groups and keywords

🐞 Bug fix 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Limit initial tag-editor height before its width is known, reducing jumps when switching entries.
• Document the reduced flicker in the changelog; a slight flicker may remain.
Diagram

graph TD
  A["Entry switch"] --> B["Tags editor"] --> C{"Width known?"} -->|No| D["Single-row height"] --> F["Editor grid"]
  C -->|Yes| E["Normal height"] --> F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Fix zero-width measurement in GemsFX
  • ➕ Addresses the underlying FlowPane measurement behavior for all consumers.
  • ➖ Requires an upstream change and dependency update, delaying this targeted fix.

Recommendation: Use the local height override to reduce the immediate entry-editor jump, and report the zero-width behavior upstream. The remaining flicker still needs investigation.

Files changed (2) +25 / -0

Bug fix (1) +24 / -0
TagsEditor.javaBound initial tag-editor height to one row +24/-0

Bound initial tag-editor height to one row

• Overrides minimum and preferred height calculations while the tags field has no width, avoiding its initially inflated FlowPane height. Restores superclass calculations once width is available.

jabgui/src/main/java/org/jabref/gui/fieldeditors/TagsEditor.java

Documentation (1) +1 / -0
CHANGELOG.mdDocument reduced entry-editor flicker +1/-0

Document reduced entry-editor flicker

• Adds a user-facing note about reduced flicker when switching between entries with groups or keywords, linked to issue #17229.

CHANGELOG.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1)

Grey Divider


Remediation recommended

1. Editor height may stay one row high after tags wrap 🐞 Bug
Description
computeMinHeight and computePrefHeight return the single-row height whenever
tagsField.getWidth() <= 0, keying the branch on a child width that the enclosing TagsEditor does
not observe, so nothing signals the parent to re-query this node once a width arrives. The
zero-width height can then persist as a cached value, leaving a multi-row tags field too short and
clipping its tags; singleRowHeight also uses tagsField.prefHeight(-1), which measures the whole
field rather than one row, so the jump is reduced but not removed when many tags are present.
Code

jabgui/src/main/java/org/jabref/gui/fieldeditors/TagsEditor.java[R266-271]

+    protected double computeMinHeight(double width) {
+        if (tagsField.getWidth() <= 0) {
+            return singleRowHeight();
+        }
+        return super.computeMinHeight(width);
+    }
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `TagsEditor` height override in the tags field returns a single-row height whenever `tagsField.getWidth() <= 0`. This branch is keyed on a child's width that the parent does not observe, and the override ignores the `width` argument passed by the parent. Once the field receives a width, nothing notifies the parent to re-query this node's height, so a height cached from the zero-width pass can persist. A tags field that needs several rows is then laid out too short and clips its tags. Separately, `singleRowHeight` uses `tagsField.prefHeight(-1)`, which measures the whole field rather than one row, so with many tags the zero-width height can still span several rows and the jump is only reduced, not removed.
## Fix Focus Areas
- file/path[start_line-end_line]
## Recommended Fix
Make the height computation depend on the inputs the parent actually uses, and ensure the parent is told to re-query when the width changes. Concretely:
1. In `computeMinHeight` and `computePrefHeight`, stop branching on `tagsField.getWidth()` alone. Use the `width` argument, or call `requestLayout()` on this node when the tags field's width changes so the parent recomputes the height once a real width is available.
2. Replace `singleRowHeight` (which calls `tagsField.prefHeight(-1)`) with a measurement that reflects one row, or correct its doc comment if the whole-field height is intended.
3. Verify with a test that lays out a tags editor with many tags before and after width is known, and confirm the height grows to fit all rows without clipping.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions github-actions Bot added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed status: changes-required Pull requests that are not yet complete labels Nov 4, 2026
@Siedlerchr
Siedlerchr added this pull request to the merge queue Nov 6, 2026
@github-actions github-actions Bot added status: to-be-merged PRs which are accepted and should go into the merge-queue. and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Nov 6, 2026
Merged via the queue into JabRef:main with commit cb1ed00 Nov 6, 2026
4 checks passed
@jabref-machine

Copy link
Copy Markdown
Collaborator

Successfully created backport PR for black-forest:

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Nov 6, 2026
Siedlerchr added a commit that referenced this pull request Nov 6, 2026
…n-list

* upstream/main: (74 commits)
  Reduce layout jump of tags editors (#17555)
  [Port to main] Chore(deps-dev): Bump @modelcontextprotocol/server from 2.0.0 to 2.4.0 (#17670)
  Make arXiv fallback title matching locale independent (#17652)
  Chore(deps): Bump org.eclipse.jgit:org.eclipse.jgit.ssh.apache.agent from 7.8.0.202609011348-r to 7.8.1.202611041320-r in /versions (#17726)
  Chore(deps): Bump org.eclipse.jgit:org.eclipse.jgit from 7.8.0.202609011348-r to 7.8.1.202611041320-r in /versions (#17727)
  Chore(deps): Bump org.eclipse.jgit:org.eclipse.jgit.ssh.apache from 7.8.0.202609011348-r to 7.8.1.202611041320-r in /versions (#17728)
  Chore(deps): Bump com.dlsc.gemsfx:gemsfx from 4.6.0 to 4.7.0 in /versions (#17729)
  New Crowdin updates (#17725)
  chore(deps): update dependency com.nimbusds:oauth2-oidc-sdk to v11.39 (#17723)
  Fix numeric sorting for citationcount, day, and dayfiled columns (#17649)
  Preserve syntax highlighting when copying BibTeX in Source tab (#17392) (#17441)
  Chore(deps): Bump com.dlsc.gemsfx:gemsfx from 4.5.0 to 4.6.0 in /versions (#17721)
  Chore(deps): Bump com.konghq:unirest-java-core from 4.11.2 to 4.11.3 in /versions (#17719)
  Chore(deps): Bump org.graalvm.sdk:nativeimage from 25.4.4.1.1 to 25.5.5.0.3 in /versions (#17718)
  Chore(deps): Bump com.konghq:unirest-modules-gson from 4.11.2 to 4.11.3 in /versions (#17720)
  New Crowdin updates (#17715)
  chore(deps): update dependency org.eclipse.jgit:org.eclipse.jgit.pgm to v7.8.1.202611041320-r (#17712)
  Restrict consistency check columns to the fields of a .bst style (#17710)
  Remove OCR language handling from DoclingEngine (#17674)
  Exclude "file" field from consistency check (#17651)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: entry-editor dev: send-to-black-forest Port to the black-forest branch of JabRef/jabref-black-forest after merging (ADR-0073) first contrib size: small status: changes-required Pull requests that are not yet complete status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flickering entry editor

3 participants