franken-ui / ui

Franken UI is an HTML-first, open-source library of UI components that works as a standalone or as a Tailwind CSS plugin. It is compatible with UIkit 3. The design is influenced by shadcn/ui.
https://franken-ui.dev
MIT License
1.7k stars 23 forks source link

uk-icon duplication #31

Open Isaac-Flath opened 2 days ago

Isaac-Flath commented 2 days ago

If there is any other information that'd be helpful please let me know. I'd also love to collaborate if helpful, though I do not know the best fix to the problem.

Problem

When uk-icon is used in conjunction with hx-push-url this results in duplicated Icons with back navigation. The situation where you'd want to push the URL is when you want to return HTML partials to swap content from the server (such as a sidebar + content layout where you just replace the content), but also have back button capability.

What I am using this for

I'm working on building a wrapper around frankenui to be used with fasthtml, which is a framework for building hypermedia applications built on top of HTMX, Starlette, and Uvicorn. Here are the docs page I am working on for the frankenui wrapper (still early days/unreleased).

Fix/workaround

The workaround I have to prevent icon duplications is to use this

htmx.on("htmx:beforeHistorySave", () => {
  document.querySelectorAll("uk-icon").forEach((elt) => {elt.innerHTML = '';});});

Minimal Repro

sveltecult commented 1 day ago

Hello,

I do not know fasthtml and know just the basics of HTMX. AFAIK, HTMX works like turbolinks where we click/trigger on something, target something and replaced it with a new response. So, I do not know what's causing the duplication.