fix(#6154): layout race in instance download page#6155
Conversation
|
/gemini review |
NaN with a placeholder valueThere was a problem hiding this comment.
Code Review
This pull request simplifies the layout of TwoLineListItem by removing the ScrollPane wrapper around tagsBox and placing tagsBox directly into firstLine. It also binds the managed and visible properties of tagsBox to the presence of tags. A review comment suggests extracting the duplicate Bindings.isNotEmpty(tags) call into a local variable to avoid creating multiple binding instances and duplicate listeners, which helps reduce memory overhead and GC pressure.
…Item.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
request review(雾 |
|
To use Codex here, create a Codex account and connect to github. |
There was a problem hiding this comment.
Code Review
This pull request refactors the tag layout in TwoLineListItem by replacing the ScrollPane with a direct HBox (tagsBox) and using a Rectangle clip to handle overflow. The reviewer suggested using JavaFX property binding (bind) instead of manual listeners to synchronize the clip's dimensions with the tagsBox dimensions, which simplifies the code and reduces overhead.
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.
|
666还真能用 |
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
这个Codex好像得连自己的Codex? |
…Item.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the TwoLineListItem class by replacing the ScrollPane container for tags with a direct HBox (tagsBox) that uses a Rectangle clip to handle overflow. The reviewer suggested overriding layoutChildren() on the HBox to update the clip dimensions synchronously during the layout pass, which avoids potential visual flickering and reduces binding overhead.
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.
| var tagsBox = new HBox(8); | ||
| tagsBox.getStyleClass().add("tags"); | ||
| tagsBox.setAlignment(Pos.CENTER_LEFT); | ||
| HBox.setHgrow(tagsBox, Priority.ALWAYS); | ||
| Bindings.bindContent(tagsBox.getChildren(), tags); | ||
| var isNotEmpty = Bindings.isNotEmpty(tags); | ||
| tagsBox.managedProperty().bind(isNotEmpty); | ||
| tagsBox.visibleProperty().bind(isNotEmpty); | ||
|
|
||
| // Clip overflow tags, matching the previous ScrollPane behavior. | ||
| var clip = new Rectangle(); | ||
| tagsBox.setClip(clip); | ||
| clip.widthProperty().bind(tagsBox.widthProperty()); | ||
| clip.heightProperty().bind(tagsBox.heightProperty()); |
There was a problem hiding this comment.
在 JavaFX 中,将 clip 的宽和高属性直接绑定到 tagsBox 的 widthProperty() 和 heightProperty() 可能会导致在窗口缩放或动画过程中出现“慢一帧”的视觉闪烁(因为绑定是在布局完成后的监听器中异步/延迟更新的)。
为了确保裁剪区域与组件大小完全同步,并减少绑定带来的性能开销,更推荐的做法是重写 HBox 的 layoutChildren() 方法,在布局阶段直接同步更新 clip 的尺寸。
var clip = new Rectangle();
var tagsBox = new HBox(8) {
@Override
protected void layoutChildren() {
super.layoutChildren();
clip.setWidth(getWidth());
clip.setHeight(getHeight());
}
};
tagsBox.getStyleClass().add("tags");
tagsBox.setAlignment(Pos.CENTER_LEFT);
HBox.setHgrow(tagsBox, Priority.ALWAYS);
Bindings.bindContent(tagsBox.getChildren(), tags);
var isNotEmpty = Bindings.isNotEmpty(tags);
tagsBox.managedProperty().bind(isNotEmpty);
tagsBox.visibleProperty().bind(isNotEmpty);
// Clip overflow tags, matching the previous ScrollPane behavior.
tagsBox.setClip(clip);
Fix #6154
这边怀疑是 race condition 导致没能成功设置标签的
Height属性,所以选择了一个不大不小的值放在上面,暂时解决了问题。如果可能的话,我会尝试寻找更好的方法修好需要更多测试。该修改之后,我已无法再复现此问题,但是不排除测试姿势不对导致的复现失败。