Skip to content

Badge Text not shown #25679

Description

@DarioViva42

Description of the bug

The behavior for the badge component changed in patch release 25.2.7.

With 25.2.6 the text was shown.
With 25.2.7 the text is no longer shown.

The reason seems to be that the attribute has-content is no longer present in the dom with 25.2.7, but was in 25.2.6

This leads to the following css rule to become active:

:host(:not([has-icon])) [part="icon"], :host(:not([has-content])) [part="content"], :host(:not([has-number])) [part="number"] {
  display: none;
}

This is maybe a regression in vaadin/web-components@ac3ff22?

The simplest fix for now seems to be to manually add the attribute ourselves.

badge.getElement().callJsFunction("setAttribute", "has-content", "");

Weirdly it does not work with the following API. Vaadin seems to run some code later to remove the attribute again.

badge.getElement().setAttribute("has-content", "");

Expected behavior

The badge component should always show the text, no matter the Vaadin version.

Minimal reproducible example

@Route
public class MainView extends VerticalLayout {
	public MainView() {
		add(new Badge("Hello World"));
	}
}

25.2.6:
Image

25.2.7:
Image

Versions

  • Vaadin / Flow version: 25.2.7 (The newest Vaadin Version seems to be 25.2.7, but the newest Flow version seems to be 25.2.9, but I have no Idea what Flow version is used with Vaadin 25.2.7)
  • Java version: not relevant
  • OS version: not relevant

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions