Skip to content

8325564: ComboBox popup does not correctly resize after update when on display#2052

Open
Ziad-Mid wants to merge 9 commits into
openjdk:masterfrom
Ziad-Mid:8325564.popupSize
Open

8325564: ComboBox popup does not correctly resize after update when on display#2052
Ziad-Mid wants to merge 9 commits into
openjdk:masterfrom
Ziad-Mid:8325564.popupSize

Conversation

@Ziad-Mid
Copy link
Copy Markdown
Contributor

@Ziad-Mid Ziad-Mid commented Jan 26, 2026

Fixed popup size not changing to show more items or less when changing the number of items in ComboBox by adding a popupResize variable which triggers a request layout when there is change in items list.
Tested with the test app in bug and MonkeyTester.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8325564: ComboBox popup does not correctly resize after update when on display (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2052/head:pull/2052
$ git checkout pull/2052

Update a local copy of the PR:
$ git checkout pull/2052
$ git pull https://git.openjdk.org/jfx.git pull/2052/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2052

View PR using the GUI difftool:
$ git pr show -t 2052

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2052.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Jan 26, 2026

👋 Welcome back zelmidaoui! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 26, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the rfr Ready for review label Jan 26, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

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

The fix does not look right: I don't think the new flag is needed, but instead the popup should be properly sized.

On top of that, the fixed code does not work: the first update shows a tiny popup where most of the area is covered with scrollbars, and the second update (after 2 seconds) still displays scrollbars. The scrollbars should not be there at all:

Image Image

(on macOS retina, scale=2)

there is more: on an external monitor at scale=1, if I press the [Update] button then quickly click on the combo box, the popup is shown but very small, and it does not change:

Image

final Point2D p = getPrefPopupPosition();

final Node popupContent = getPopupContent();
if (popupResize && popupContent instanceof Region) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor stylistic suggestion:

        if (popupResize && popupContent instanceof Region r) {
            r.setMinSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
            r.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
        }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also, look in sizePopup(), there is if (popupContent instanceof Region) { with the else clause which handles other cases.

Should any possible fix be in sizePopup() instead?

popupResize = false;
}

final void requestPopupLayout() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

misnomer: the name suggests it's a request, but in fact it does much more by calling

reconfigurePopup();
sizePopup();

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

/reviewers 2

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Jan 27, 2026

@andy-goryachev-oracle
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

Copy link
Copy Markdown
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

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

The last change is a step in the right direction. Three issues:

  1. Please merge the latest master, there was a change in sizePopup() which makes your code fail to compile. In general, it's a good idea to merge the latest master if your PR is long going or there was a change in a related area.
  2. The reproducer shows the popup in the body of the first KeyFrame via comboBox.show();. Once the popup is shown, the second background update does not resize the popup and you see the scrollbars.
  3. If you remove the comboBox.show(); line, the expectation is that the popup will not be shown, but it is, resulting in this:
Image

Also, I've noticed the size of the popup control in the step 2 changes (also present in the master branch, so I guess it's expected)

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

@crschnick would you be able to review this PR?

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

andy-goryachev-oracle commented Feb 2, 2026

Looks much better!

Two things:

  1. please change the copyright year to 2026
  2. noticed runLater() in recomputePopupLayout(), so I decided to apply CSS to the popup. You can use
    https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/ComboBox_PopupSize_8325564.java

On my primary retina display I get the scrollbars first time around. The scrollbars disappear on second showing:

Screenshot 2026-02-02 at 15 05 29
.combo-box-popup > .list-view {
    -fx-padding: 100px
}

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Mar 3, 2026

@Ziad-Mid This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Mar 3, 2026

@Ziad-Mid This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper Bot closed this Mar 3, 2026
@crschnick
Copy link
Copy Markdown
Member

@crschnick would you be able to review this PR?

Sorry, I didn't see this comment until now. I can take a look

Also what happened to bridgekeeper? That inactivity timeout looks wrong

@crschnick
Copy link
Copy Markdown
Member

@andy-goryachev-oracle Can I still review this?

@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

Let me check with @Ziad-Mid ...

@kevinrushforth
Copy link
Copy Markdown
Member

Also what happened to bridgekeeper? That inactivity timeout looks wrong

Yes, this looks like a hiccup of some sort. The initial "inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes..." was correct. The "hey it's been 4 more weeks" auto-close one hour later was not. I'm reopening it.

@kevinrushforth kevinrushforth reopened this Mar 3, 2026
@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

... and I think @Ziad-Mid is still working on it, #2052 (comment) has not been addressed.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 4, 2026

@Ziad-Mid This pull request is already open

@Ziad-Mid
Copy link
Copy Markdown
Contributor Author

Ziad-Mid commented Mar 4, 2026

... and I think @Ziad-Mid is still working on it, #2052 (comment) has not been addressed.

Yes, I still do

@openjdk openjdk Bot removed the rfr Ready for review label Apr 22, 2026
@Ziad-Mid
Copy link
Copy Markdown
Contributor Author

/template append

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Apr 22, 2026

@Ziad-Mid The pull request template has been appended to the pull request body

@openjdk openjdk Bot added the rfr Ready for review label Apr 22, 2026
@andy-goryachev-oracle
Copy link
Copy Markdown
Contributor

So I think the problem identified in #2052 (comment) is still there.

I've updated the test not only to add items but also remove them (making the list smaller, just in case) - see the latest version
https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/ComboBox_PopupSize_8325564.java

to reproduce,

  • click the combobox to show the popup,
  • click elsewhere to dismiss the popup
  • click update button
  • open the popup again

Expecting to see no scrollbar, but:

Screenshot 2026-04-22 at 12 12 08

Copy link
Copy Markdown
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

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

still see the scrollbar.

@crschnick
Copy link
Copy Markdown
Member

In general I would say that if you have to rely on using Platform.runLater for some kind of layouting and size changes within a Control or Skin, the approach is usually not the right one. I would try to replace the runLater call with another implementation that fixes the issue as well somehow.

@Ziad-Mid
Copy link
Copy Markdown
Contributor Author

Ziad-Mid commented May 6, 2026

Tested with latest test from Andy and it works.

@crschnick
Copy link
Copy Markdown
Member

While fixing https://bugs.openjdk.org/browse/JDK-8338145, I found the cause to be the fact that the popup did not have the right size computed before the first show. That is why the fix calls sizePopup() twice. Maybe this issue is related and somehow eliminates the need to call sizePopup() twice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rfr Ready for review

Development

Successfully merging this pull request may close these issues.

4 participants