carlosescri

carlosescri

LiveView DOM patching in webcomponents with slotted content

Hi all!

I’ve been working on some RAW (no framework) web components for one of our projects to see how well they behave with Phoenix LiveView.

At the time I have:

  • Custom tooltips (no problem)
  • Phone Input with country dropdown picker (no problem), Form Associated Custom Element (FACE), so it works with forms as any other input.
  • Custom Select (with search and a slot to put custom HTML nodes). FACE too.

I had some problems with the slotted elements in the custom select because they were not patched by morphdom.

With a bit of help from Claude y proposed a fix in the live view repo.

You can get more details here:

If any of you is interested on this topic because you suffered from this problem too, would be great if you can give a try so @steffend can get some feedback because this is actually a bit tricky.

I encourage you to take a look at the PR. It’s up to date to 1.2.6 version of LV and it has some tests. More details in the PR.

Thank you for your time.

First 4 of 4 Posts Switch mode

krasenyp

krasenyp

I had a perfectly running web component with slotted elements, at 1.1.9. After I updated to the newest LiveView, at the time it was 1.2.2, everything stopped working. I had to rewrite my components as stateless components… I hope your fix gets approved and we can write our web components without worry.

carlosescri

carlosescri OP

Thanks for your response… if you have means and time, would be great if you could try your web components (or some of them) with the JS in the PR to check if they work again… Thank you in any case.

steffend

steffend

Phoenix Core Team

That looks like a bug. Can you please open up an issue with some details on this?

carlosescri

carlosescri OP

@steffend created a better fix here: Allow opting focused form elements into patching by SteffenDE · Pull Request #4339 · phoenixframework/phoenix_live_view · GitHub

In my case I can confirm this fixed all my problems with light dom patching. I hope it gets merged soon.

— All posts loaded —

Where Next?

Trending in Thoughts On... Top

carlosescri
Hi all! I’ve been working on some RAW (no framework) web components for one of our projects to see how well they behave with Phoenix Liv...
New
preciz
I had a lot of back and forth with Codex CLI & GPT 5.6 Sol to use a SWAR optimization for URI.encode_www_form/1. I now have a versio...
New
odix67
Hi, I have to build an app also on windows, since some time, I do not know it exactly, I ran into the the issue below during download of...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement