diff --git a/apps/client/src/services/attribute_autocomplete.ts b/apps/client/src/services/attribute_autocomplete.ts index 0fbf78ec28..57f2e724b6 100644 --- a/apps/client/src/services/attribute_autocomplete.ts +++ b/apps/client/src/services/attribute_autocomplete.ts @@ -217,6 +217,9 @@ function initAttributeNameAutocomplete({ $el, attributeType, open, onValueChange inputEl.removeEventListener("blur", onBlur); inputEl.removeEventListener("keydown", onKeyDown); stopPositioning(); + if (panelEl.parentElement) { + panelEl.parentElement.removeChild(panelEl); + } }; instanceMap.set(inputEl, { autocomplete, panelEl, cleanup }); @@ -292,7 +295,17 @@ async function initLabelValueAutocomplete({ $el, open, nameCallback }: LabelValu } } +export function destroyAttributeNameAutocomplete($el: JQuery | HTMLElement) { + const inputEl = $el instanceof HTMLElement ? $el : $el[0] as HTMLInputElement; + const instance = instanceMap.get(inputEl); + if (instance) { + instance.cleanup(); + instanceMap.delete(inputEl); + } +} + export default { initAttributeNameAutocomplete, + destroyAttributeNameAutocomplete, initLabelValueAutocomplete, };