Disabled actions unless dirty inputs #20001
Replies: 3 comments 1 reply
-
|
@danharrin Hmm, any thoughts? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I think I am going to pass on this one, I imagine there are quite a few edge cases with complex field states like repeater and file upload, and it has not been requested by enough users to warrant that extra maintenance burden. Luckily it looks quite easy to implement with |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the feedback! Just a quick note — I'll look into a proper approach that handles edge cases (repeater, file upload, etc.) without adding fragile maintenance surface, and will open a PR if I find something solid. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey @danharin 👋
I'd love to open a discussion around a feature idea: disabling form actions until the form is "dirty" — leveraging Livewire's built-in dirty tracking.
💡 The Idea
Allow actions (e.g. Save, Submit) to be conditionally disabled until the user has actually made a change to the form.
I've already tested this on my own and it worked really well. The proposed signature would look something like:
Mirroring how Livewire's dirty tracking works, it could also accept two optional arguments — a condition and the IDs of target components to watch — so you can scope dirty-checking to specific fields:
⚙️ Implementation Approach
The implementation would use
wire:dirtyas the primary mechanism where it fits naturally. For cases wherewire:dirtyisn't applicable, it would fall back to Alpine'sx-bindwith$wire.$dirty(targets)— giving us the flexibility to handle both simple and advanced use cases cleanly:This keeps the API consistent with how dirty tracking already behaves in the Livewire + Alpine ecosystem: https://livewire.laravel.com/docs/dirty
✅ UX & UI Benefits
Since this builds on top of mechanisms already present in the Livewire + Alpine stack, the implementation footprint should be small. Happy to make a PR if there's interest.
Would love to hear your thoughts!
Beta Was this translation helpful? Give feedback.
All reactions