Skip to content

Commit

Permalink
fix: tooltip wrapper doesn't destroy (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxming authored Jan 11, 2025
1 parent f7421dd commit 4c238fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class QuillToolbarTip {
}
return currentControlResult || result;
},
appendTo: this.quill.container,
});
if (instance) {
this.toolbarTips.push([toolName, instance]);
Expand Down
4 changes: 3 additions & 1 deletion src/utils/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface TooltipOptions {
className: string | string[];
tipHoverable: boolean;
onShow: (target: HTMLElement) => string | HTMLElement | undefined | null;
appendTo: HTMLElement;
}
export interface TooltipInstance {
instance: HTMLElement;
Expand All @@ -41,6 +42,7 @@ export const createTooltip = (target: HTMLElement, options: Partial<TooltipOptio
className = [],
tipHoverable = true,
onShow,
appendTo = document.body,
} = Object.assign({}, tooltipDefaultOptions, options);
if (isString(className)) {
className = ensureArray(className.split(' '));
Expand Down Expand Up @@ -98,7 +100,7 @@ export const createTooltip = (target: HTMLElement, options: Partial<TooltipOptio

if (!tooltipContainer) {
tooltipContainer = document.createElement('div');
document.body.appendChild(tooltipContainer);
appendTo.appendChild(tooltipContainer);
}
tooltipContainer.appendChild(tooltip);
tooltip.removeEventListener('transitionend', transitionendHandler);
Expand Down

0 comments on commit 4c238fb

Please sign in to comment.