Skip to content

Commit

Permalink
🐛 fix: broken hints with aplinejs or htmx
Browse files Browse the repository at this point in the history
  • Loading branch information
niketpathak committed Oct 4, 2024
1 parent 8724bf9 commit 6645d61
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/typeahead-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ const typeahead = <T extends Dictionary>(config: typeaheadConfig<T>): typeaheadR

// generate markup for hints
const inputHint: HTMLInputElement = input.cloneNode() as HTMLInputElement;

// remove special attributes like those used with alpineJS or htmx from hint element
const attrRegex = /^(x-|hx-|data-|@)/;
for (let i = inputHint.attributes.length - 1; i >= 0; i--) {
const attrName = inputHint.attributes[i].name;
if (attrRegex.test(attrName)) {
inputHint.removeAttribute(attrName);
}
}

hint && injectHintEl(inputHint);

listContainer.classList.add(classNames.list, classNames.hide);
Expand Down

0 comments on commit 6645d61

Please sign in to comment.