Problem
Within a stimulus controller action, event.preventDefault is not stopping the ajax request created with remote: true from a link_to element
Expected
I would expect event.preventDefault to stop the ajax request as I believe it does with button_to etc.
Sample code
````erb
<%= link_to 'New Article', new_article_path, remote: true, data: {action: "hello#testPreventDefault"} %>
````
js
//hello_controller.js
testPreventDefault(event){
event.preventDefault()
}
Output
The logs show the new route is accessed even though event.preventDefault() is called:

Sample repo
event.preventDefault() only prevents the link from being followed. event.stopImmediatePropagation() will stop the event from being propagated to other event handlers.
@fourcube thanks for taking the time to help.
With event.stopImmediatePropagation() the request still went through but this time as HTML rather than JS:

@fourcube I think I must have misunderstood your answer. When I use both preventDefault() and stopImmediatePropagation() together it works which is what I think you were referring to. So the solution is
js
testPreventDefault(event){
event.preventDefault()
event.stopImmediatePropagation()
}
Seems I have some reading to do. Thanks again.
Most helpful comment
event.preventDefault()only prevents the link from being followed.event.stopImmediatePropagation()will stop the event from being propagated to other event handlers.