Skip to content

Fix: Lock AccountListItemSkin.btnRefresh width to prevent layout shifting#6369

Open
KSSJW wants to merge 1 commit into
HMCL-dev:mainfrom
KSSJW-Contribution:account-list-item-skin-btn-refresh-fix
Open

Fix: Lock AccountListItemSkin.btnRefresh width to prevent layout shifting#6369
KSSJW wants to merge 1 commit into
HMCL-dev:mainfrom
KSSJW-Contribution:account-list-item-skin-btn-refresh-fix

Conversation

@KSSJW

@KSSJW KSSJW commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

修复了AccountListItemSkin中刷新按钮在showSpinner后大小更改的问题

问题复现

_20260711_131828.mp4

@KSSJW

KSSJW commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request sets a preferred size of 30.0x30.0 on the spinnerRefresh component in AccountListItemSkin.java. It is recommended to define these dimensions in the CSS stylesheet under the .small-spinner-pane class instead of hardcoding them in Java to improve maintainability and ensure consistent layout behavior across other components using the same class.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

JFXButton btnRefresh = FXUtils.newToggleButton4(SVG.REFRESH);
SpinnerPane spinnerRefresh = new SpinnerPane();
spinnerRefresh.getStyleClass().setAll("small-spinner-pane");
spinnerRefresh.setPrefSize(30.0, 30.0);

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.

medium

Instead of hardcoding the preferred size of spinnerRefresh in Java code, it is more maintainable and consistent to define these dimensions in the CSS stylesheet under the .small-spinner-pane class (e.g., using -fx-pref-width: 30px; -fx-pref-height: 30px;). This ensures that all components using .small-spinner-pane (such as spinnerMove and spinnerUpload) behave consistently and avoid layout shifting without duplicating layout code in Java.

@KSSJW

KSSJW commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

setPrefSize(30.0, 30.0)是因为前面还使用了newToggleButton4(对应 CSS toggle-icon4

.toggle-icon4 {
    -fx-toggle-icon4-size: 30px;
    -fx-pref-width: -fx-toggle-icon4-size;
    -fx-max-width: -fx-toggle-icon4-size;
    -fx-min-width: -fx-toggle-icon4-size;
    -fx-pref-height: -fx-toggle-icon4-size;
    -fx-max-height: -fx-toggle-icon4-size;
    -fx-min-height: -fx-toggle-icon4-size;
    ...
}

若更改 CSS small-spinner-pane ,则其他使用了该样式的组件也会受影响(例如DownloadDiscoJava),即使他们 没有 使用 toggle-icon4

@KSSJW KSSJW left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed

@KSSJW KSSJW marked this pull request as ready for review July 11, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant