Created
December 27, 2023 11:25
-
-
Save TatuLund/a5e90546696cfd081f2aefafdfbaece2 to your computer and use it in GitHub Desktop.
There is no API in Vaadin 24 yet for setting overlay classname of the tooltip. You can use the following JavaScript utility function with Vaadin 24.2.0 and nwer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TooltipUtils { | |
| public static void setTooltipClassName(Component comp, String className) { | |
| comp.getElement().executeJs( | |
| """ | |
| if ($0.getElementsByTagName('vaadin-tooltip').length == 1) { | |
| $0.getElementsByTagName('vaadin-tooltip')[0]._overlayElement.setAttribute('class',$1); | |
| } else { | |
| const tooltips = document.getElementsByTagName('vaadin-tooltip'); | |
| for (let i=0; i<tooltips.length; i++ ) { | |
| const tooltip = tooltips[i]; | |
| if (tooltip.children[0].id === $0.getAttribute('aria-describedBy')) { | |
| tooltip._overlayElement.setAttribute('class',$1) | |
| } | |
| } | |
| } | |
| """, comp.getElement(), className); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment