-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Live] Smart Rendering! Mix/match live components with external JavaScript #728
Conversation
2fad426
to
2ad5749
Compare
Can't wait to get back to work tomorrow to try this black magic, good job <3 |
2ad5749
to
d142431
Compare
Fixing a bug I just found - where the |
And... here's the fix: symfony/stimulus-bridge#81 - using the latest version of |
I've got a problem with this philosophy: In live component i have a list of checkboxes. Each checkbox has it's own stimulus controller which has configured custom Simultaneously I have an live component action which changes the |
Thanks for bringing this up @norkunas - I figured there would be some real-world hiccups we'd need to work through.
That makes sense. Question: BEFORE the new re-rendering system, did you have the opposite problem? When the Stimulus controller added the checked class, when the live component re-rendered (not via the action, just a normal re-render), didn't it NOT include the custom class? And so, didn't the re-render cause the custom class to be lost? Or do you have the "if checked -> add custom class" logic both inside of Twig and also include if your Stimulus controller? And if so, why do you have it in both places? Is it just to make the experience feel faster / more responsive (i.e. as SOON as the user checks the box, the class is added, without needing to wait for the re-render)? Btw, feel free to open a new issue - I don't want this to get lost on a merged PR - I sometimes catch these notifications, and sometimes not :) |
Hi, |
Hoping within a week - only waiting for 2 minor bug fixes with new twig syntax |
Hello community I come to you with a similar problem. |
@ag-erwan Did yo solve you issue? I'm facing the same problem I think |
Hi!
This fixes the biggest pain-point with LiveComponents: mixing them with custom JavaScript. Before this PR, a lot of things were difficult/weird: keeping modals open, collapsing content (#702), using JS widgets like Autocomplete or a date picker, and more. The best part? Everything works automatically with you needing to do anything.
With this PR, a new philosophy is born: start with a live component, then mix in any "extras" you want with Stimulus controllers.
The new "smart rendering" system isn't designed to catch everything (see the docs), but I think it will catch 95%+ of the situations. Here are 2 cool things that now work out-of-the-box:
A) ux-autocomplete + Live components works perfectly now - even if the available options completely change - the "dependent form fields" example has been updated to use autocomplete on both fields 🔥
ScreenFlow.mp4
B) I added a new demo of Live Components + Autocomplete + Chartjs. What you see is done without needing to write any JavaScript:
live-chart.mp4
How Does it Work?
If you care about the technical details, we leverage a
MutationObserver
to watch your component for changes made by anything other than live components. Those changes are "tracked". Then, during re-render, we use that info to keep those custom changes.Cheers!