Skip to content
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

fix(tooltip): only show tooltip that has value #1511

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/common/src/core/slickGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6296,13 +6296,14 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}

/**
* Sanitize possible dirty html string (remove any potential XSS code like scripts and others) when provided as grid option
* @param dirtyHtml: dirty html string
* Sanitize possible dirty html string (remove any potential XSS code like scripts and others) when provided via `sanitizer` grid option.
* The logic will only call the sanitizer if it exists and is a defined string, anything else will be skipped (number, boolean, TrustedHTML will all be skipped)
* @param {*} dirtyHtml: dirty html string
*/
sanitizeHtmlString<T extends string | TrustedHTML>(dirtyHtml: string): T {
if (typeof this._options?.sanitizer === 'function') {
return this._options.sanitizer(dirtyHtml) as T;
sanitizeHtmlString<T extends string | TrustedHTML>(dirtyHtml: unknown): T {
if (typeof this._options?.sanitizer !== 'function' || !dirtyHtml || typeof dirtyHtml !== 'string') {
return dirtyHtml as T;
}
return dirtyHtml as T;
return this._options.sanitizer(dirtyHtml) as T;
}
}
2 changes: 1 addition & 1 deletion packages/custom-tooltip-plugin/src/slickCustomTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export class SlickCustomTooltip {
}

// when do have text to show, then append the new tooltip to the html body & reposition the tooltip
if (finalOutputText) {
if (finalOutputText.toString()) {
document.body.appendChild(this._tooltipElm);

// reposition the tooltip on top of the cell that triggered the mouse over event
Expand Down
Loading