preline icon indicating copy to clipboard operation
preline copied to clipboard

Error when using Radix components together

Open luanfonsecap opened this issue 2 years ago • 0 comments

With the new instruction to start HSStaticMethods:

const location = useLocation();

useEffect(() => {
    HSStaticMethods.autoInit();
  }, [location.pathname]);

Described here https://preline.co/docs/frameworks-react.html.

Using tabs component from Radix, application crash with error when reload the page. image

Or when paste the tabs component radix code without reload the page, the Carousel component does not work inside a Tabs.Content. image

https://github.com/htmlstreamofficial/preline/assets/43269295/53d1e14a-675f-4c7f-9c82-4afbd3379d81

Update

I have founded where is the problem, when starting HSStaticMethods and using Radix components that uses role attributes were also used by Preline on query selector's inside autoInit method, they found radix components when crash when execute some constructor logic.

The query for Preline tabs component to find them inside auotInit method the expression used for query selection does not work as expected, even using the class "prevent-on-load-init", the element is found.

The correct expression should be: [role="tablist"]:not(select):not(.prevent-on-load-init).

And i suggest to use another attribute to load Preline components on autoInit to not merge non Preline components to prevent errors like this, something like [role="tablist"][data-preline]:not(select):not(.prevent-on-load-init).

luanfonsecap avatar Dec 22 '23 18:12 luanfonsecap