htmlstreamofficial / preline

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
https://preline.co
Other
4.9k stars 309 forks source link

Conflict using Splide JS with Preline Tabs #321

Closed shamssujon closed 5 months ago

shamssujon commented 7 months ago

I am getting the console error "Uncaught TypeError: Cannot read properties of undefined (reading 'getAttribute')" when trying to use the Splide JS in a project where Preline is installed.

Screenshot 2024-03-29 070247

I believe this is because of a conflict with the Tabs plugin. It requires role="tablist", role="tab", role="tabpanel" and it is conflicting with the Splide JS. I looked into the Preline codes and found this:

document.querySelectorAll('[role="tablist"]:not(select):not(.--prevent-on-load-init)').forEach()

which is not a good way to target the tabs in my opinion. Because there might be other elements using the same role attribute.

Any suggestion on how to fix this?

zhi8617 commented 7 months ago

Same problem, when I introduce.

umaraziz0 commented 6 months ago

Same issue here, in my case it's conflicting with shadcn-vue's Tabs, which is based on radix-ui tabs

umaraziz0 commented 6 months ago

Update:

I've found a temporary fix is to use autoInit() only on components that you use, and since I only use the Advanced Select, my configuration on nuxt.js would be:


export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hook('page:finish', () => {
    window.HSStaticMethods.autoInit(['select']);
  });
});
jahaganiev commented 5 months ago

We will revisit role="tablist" init approach in v3.0 Preline.

Meanwhile, you may add --prevent-on-load-init class where tablist is used for this specific case.

Cheers!