JDK 8210037 : ComboBoxes in GridPane resize when popup opens
So the issue was that when two or more ComboBox controls with Priority.ALWAYS HGrow are placed in a GridPane, opening and closing one ComboBox's popup caused the column widths to become unequal.
The root cause I believe is in reconfigurePopup( ) in ComboBoxPopupControl. While the popup is showing, it calls setPrefSize( ) on the popup content (the ListView) to stabilize its displayed size. This pins the ListView's preferred width to the current popup dimensions. When the popup closes and the GridPane performs its next layout pass, computePrefWidth in ComboBoxListViewSkin reads listView.prefWidth( ) which for the ComboBox whose popup was just open returns the stale pinned value, while the other ComboBox computes dynamically. This asymmetry causes GridPane to allocate unequal column widths.
I first tried resetting setPrefSize to USE_COMPUTED_SIZE in the WINDOW_HIDDEN handler. This approach does look clean I guess but doesn't work cause the GridPane layout pass that reads computePrefWidth happens while the popup is still showing, so the reset fires too late and the asymmetric value is already committed.
The fix I've used :
Guard computePrefWidth in ComboBoxListViewSkin: when the popup is not showing, we compute the ListView width dynamically via a new private method computeListViewPrefWidth( ) instead of reading the potentially stale listView.prefWidth( ).
When the popup is showing, the pinned value is still used directly and this preserves the existing popup stability behavior from JDK-8116801 and JDK-8123876.
The measurement logic in computeListViewPrefWidth was already present in the anonymous ListView subclass's computePrefWidth override. All I did was extract it into a named method to eliminate the duplication.
- [x] I confirm that I make this contribution in accordance with the OpenJDK Interim AI Policy.
Progress
- [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
- [x] Change must not contain extraneous whitespace
- [ ] Commit message must refer to an issue
Error
⚠️ OCA signatory status must be verified
Reviewing
Using git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2182/head:pull/2182
$ git checkout pull/2182
Update a local copy of the PR:
$ git checkout pull/2182
$ git pull https://git.openjdk.org/jfx.git pull/2182/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2182
View PR using the GUI difftool:
$ git pr show -t 2182
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2182.diff
Hi @faneeshh, welcome to this OpenJDK project and thanks for contributing!
We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.
If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user faneeshh" as summary for the issue.
If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.
❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.
/signed
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!
@faneeshh Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.