Preventing event from a button in an accordion header refreshes the page #3299
Description
Version 0.12 introduced a problem with my use case. I have an accordion, and in its header I have several buttons. When clicking these buttons, the default behavior is to execute the action of that button and toggling the body content.
In order to prevent this, I capture the $event
in the binding, and call its stopPropagation()
in the button handler.
As of version 0.12 this causes a refresh of the page.
See the bug reproduced in Plunker.
I've found the problem to be originating from commit 992b232, where a href
attribute was added to the header, in order for the keyboar navigation to focus on the link element. However, in turn, the browser will hook up a default handler to navigate to the empty URL. This navigation happens when the $event is stopped propagating, like in my example.
I've found the solution to be to attach a noop to the href attribute; href="javascript:void(0)"
. This keeps the keyboard navigation working, and when stopping the event, still has the expected behavior of just cancelling the accordion toggle.