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(settings): reset tooltip on HTML append #1444

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 22 additions & 5 deletions ui/settings/settings.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
// @ts-nocheck

function appendHTML(parent, html) {
var div = document.createElement("div");
div.innerHTML = html;
while (div.children.length > 0) {
parent.appendChild(div.children[0]);
// Create a temporary container for the HTML string
const tempDiv = document.createElement("div");
tempDiv.innerHTML = html;

// Move all child elements from the temporary container to the parent
while (tempDiv.children.length > 0) {
parent.appendChild(tempDiv.children[0]);
}
div.remove();

// Remove the temporary container to clean up the DOM
tempDiv.remove();

// Destroy all existing tooltips to prevent duplication
const tooltipElements = document.querySelectorAll('[data-toggle="tooltip"]');
tooltipElements.forEach((tooltip) => {
if ($(tooltip).data("bs.tooltip")) {
$(tooltip).tooltip("dispose");
}
});

// Reinitialize tooltips for the updated elements
$('[data-toggle="tooltip"]').tooltip({ container: "body" });
}


const vscode = acquireVsCodeApi();

const textInputTemplate = `<div class="form-group mb-4">
Expand Down