-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Badge implement HasTooltip #10
Comments
I've been investigating this and according to the HasTooltip interface documentation I don't think adding the implementation od the interface is the right way to go here. It says "Components that implement this interface get a element added inside thecomponent's light DOM and are expected to handle it appropriately on theclient-side. Use this interface ONLY if you are implementing a new component that also has a Web Component counterpart with a custom tooltip support. Otherwise, use Tooltip.forComponent(Component) instead". This is not the case of the Badge class, as it is only a extension of Span class thus it has no web-component counterpart, meaning that it has no support for the HasTooltip interface. Badge b = new Badge();
b.addThemeName(BadgeVariant.CONTRAST.getVariantName());
b.getStyle().setCursor("pointer");
Tooltip.forComponent(badge)
.withText(getTranslation("snaplets.usermanager.viewsview.hardcodedroles.tooltip"))
.withPosition(Tooltip.TooltipPosition.TOP_START); If the implementation of the HasTooltip interface it's still required, then a refactor of the Badge class should be needed in order to have a web-component part that could give support to vaadin-tooltip. |
The following works (24.2.2):
After vaadin/flow-components#5676 is merged the following should also work:
NOTE WELL I'm not suggesting that we must implement it in this manner. Rather, it's a response to the argument that, "if the implementation of the HasTooltip interface is still necessary, then a refactoring of the Badge class would be required to include a web-component part that could provide support for vaadin-tooltip." |
It would be useful if each Badge could display a tooltip when hovering over it.
As a workaround I made it work with this code:
The text was updated successfully, but these errors were encountered: