KEMBAR78
feat: add tooltip content-changed event and use it in controller by web-padawan · Pull Request #10045 · vaadin/web-components · GitHub
Skip to content

Conversation

@web-padawan
Copy link
Member

Description

Related to #10008 - see #10008 (comment)

Added an event that can be used in TooltipController to fire its own event - IMO it's ok to also keep it as public because currently there is no way to detect when tooltip text is changed without observing DOM nodes.

Type of change

  • Feature

await nextFrame();

spy.resetHistory();
fire(tooltip, 'content-changed');
Copy link
Member Author

Choose a reason for hiding this comment

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

These tests don't actually import vaadin-tooltip so we can't use its API and have to fire event manually.

/** @private */
__updateContent() {
this.__contentNode.textContent = typeof this.generator === 'function' ? this.generator(this.context) : this.text;
this.dispatchEvent(new CustomEvent('content-changed', { detail: { content: this.__contentNode.textContent } }));
Copy link
Member Author

Choose a reason for hiding this comment

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

Checking textContent after setting it to always return a string if null or undefined was set.

@web-padawan web-padawan force-pushed the feat/tooltip-content-changed branch from 92b3420 to 6af088b Compare August 20, 2025 13:44
@sonarqubecloud
Copy link

@web-padawan web-padawan merged commit 47c3586 into main Aug 20, 2025
9 checks passed
@web-padawan web-padawan deleted the feat/tooltip-content-changed branch August 20, 2025 14:05
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