You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #950 [Live] Fixing bug with data-action="live#update" and inside clickable elements (weaverryan)
This PR was merged into the 2.x branch.
Discussion
----------
[Live] Fixing bug with data-action="live#update" and inside clickable elements
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Tickets | None
| License | MIT
Small bug fix:
```
<a
data-action="live#update"
data-model="name"
data-value="Dan"
><span>Change name to Dan</span></a>
```
In this case, the "click" would actually happen on the `span`, which is `event.target`. Switched to `event.currentTarget` to get the element that the listener is actually attached to (the `a`).
Cheers!
Commits
-------
9a5c60b [Live] Fixing bug with data-action="live#update" and inside clickable elements
Copy file name to clipboardExpand all lines: src/LiveComponent/assets/dist/live_controller.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2697,9 +2697,9 @@ class LiveControllerDefault extends Controller {
2697
2697
}
2698
2698
update(event){
2699
2699
if(event.type==='input'||event.type==='change'){
2700
-
thrownewError(`Since LiveComponents 2.3, you no longer need data-action="live#update" on form elements. Found on element: ${getElementAsTagText(event.target)}`);
2700
+
thrownewError(`Since LiveComponents 2.3, you no longer need data-action="live#update" on form elements. Found on element: ${getElementAsTagText(event.currentTarget)}`);
0 commit comments