Skip to content

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Jan 9, 2026

代码由 Claude Opus 4.5 生成。

getChildren().addAll(tagLabels);

// Ensure collapsed indicator is on top
collapsedIndicator.toFront();
Copy link
Contributor

@Mine-diamond Mine-diamond Jan 10, 2026

Choose a reason for hiding this comment

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

Suggested change
collapsedIndicator.toFront();
collapsedIndicator.toFront();
this.applyCss();

我找到了一个解决办法,之所以会出现标签没办法渲染,主要原因是部分情况下重新布局时,标签Label没有正确应用css,这导致Label的尺寸为0,可以强制applyCss来解决

可能的原因如下:

content.getTags().clear();
dataItem.getCategories().stream()
.map(category -> getSkinnable().getLocalizedCategory(category))
.forEach(content::addTag);

在这里,由于选中组件导致updateControl被执行,因为导致标签被重新添加,会触发这个逻辑,导致tagLabel重建

    private void rebuildTagLabels() {
        // Remove old labels
        getChildren().removeAll(tagLabels);
        tagLabels.clear();

        // Create new labels
        for (Tag tag : tags) {
            Label label = new Label();
            label.setText(tag.text());
            label.setManaged(false);
            label.getStyleClass().add(tag.warning() ? "tag-warning" : "tag");
            tagLabels.add(label);
        }
        ...

但问题在于,选中本身也导致更新css,这导致选中列表时会同时更新css和更新tagLabel以及重新布局,这可能导致一些bug,导致在layoutChildren时新的tagLabels根本没有应用css。
我不能确定一定是因此产生的bug,但是我可以确认的是,重新布局时,新的Label确实没有正确应用css,这导致新的Label的尺寸为0

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.

2 participants