mdbootstrap / TW-Elements

𝙃𝙪𝙜𝙚 collection of Tailwind MIT licensed (free) components, sections and templates 😎
https://tw-elements.com
MIT License
12.9k stars 1.62k forks source link

[Select] [duplication of select component when reinitializing it] #2345

Open memiljamel opened 5 months ago

memiljamel commented 5 months ago

I found the same problem here #1891. The solution provided works, but there are duplicate elements in the select component. I have also asked there, but there has been no response.

Here's the screenshot: Capture

1

does anyone know why this happens?

juujisai commented 5 months ago

Hi, the issue was closed thats why we missed it.

You can try checking whether the instance exists before calling initTE again (in side the life cycle method, or other place you are using it)

This could look something like this:

if (!Select.getInstance(mySelectInstance) {
  initTE({Select})
}

The initTE method with flag allowReinits creates a new instance for components and does not check whether components were initialized before or not. Checking whether the instance exists before calling it should work here