pattern-library icon indicating copy to clipboard operation
pattern-library copied to clipboard

axa-link reason for onClick's event.preventDefault() ?

Open MarekLacoAXA opened this issue 3 years ago • 2 comments

Axa-link is preventing default event on click. This is documented.

As this is counter-intuitive (compared to dom's anchor element), I am missing reason for this behavior.

From my consumer point-of-view, this is a downside, because it forces me to use both href attribute (for usability) and call in onClick handler the history.push() again, so that the navigation even works. (As I am attaching other functionality in onClick handler also).

Ideally, there would no e.preventDefault() be called in axa-link at all. As I can do that myself when I need to. As the event is passed down already since v 4.2.23, see:

Thanks!

image

MarekLacoAXA avatar Oct 14 '21 07:10 MarekLacoAXA

I think we had this issue already at some point, no?

I don't remember the reason. Maybe it was the consideration of the external attribute. But I currently don't see why we should not do that.

Since this is a feature request, I have to discuss it with @markus-walther and he is on vacation for this and next week.

raphaellueckl avatar Oct 14 '21 15:10 raphaellueckl

Discussion: We should leave preventDefault as default behavior, but add an attribute to disable this behavior.

raphaellueckl avatar Nov 29 '21 10:11 raphaellueckl

@MarekLacoAXA I agree with you. The User should also just know that he has to use the ev.preventDefault(); himself if he does not use link natively.

I will remove prevent default and also window open.

It will be breaking change and new major version.

MKaHead avatar Sep 07 '22 13:09 MKaHead

I approve of the decision of @MKaHead - it makes a lot of sense and simplifies the component.

markus-walther avatar Sep 12 '22 08:09 markus-walther