Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.jackhuang.hmcl.ui.account;

import com.jfoenix.controls.JFXPopup;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.WeakInvalidationListener;
import javafx.beans.binding.Bindings;
Expand Down Expand Up @@ -64,6 +65,8 @@ public AccountListPopupMenu() {
});
box.add(item);
}

Platform.runLater(() -> box.setVvalue(Double.MIN_VALUE));
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

Using Double.MIN_VALUE to reset the scroll position is semantically incorrect. In Java, Double.MIN_VALUE is the smallest positive non-zero value ($4.9 \times 10^{-324}$), not the minimum possible value (which would be -Double.MAX_VALUE). For a ScrollPane's vvalue, the valid range is typically 0.0 to 1.0. While Double.MIN_VALUE is effectively 0.0 due to precision, it is clearer and more idiomatic to use 0.0 or box.getVmin().

Suggested change
Platform.runLater(() -> box.setVvalue(Double.MIN_VALUE));
Platform.runLater(() -> box.setVvalue(0.0));

};
listener.invalidated(null);
Accounts.getAccounts().addListener(new WeakInvalidationListener(listener));
Expand Down