I want to call function A , when someone clicks on the icon of the details and function B when the summary or text section of this detail summary / text is clicked.
<details @click="function-A">
<summary @click="function-B">
Some Text
</summary>
</details>
I tried everything, I also used some event modifiers, but it did not work as expected
2
Answers
The arrow icon is a
::marker
pseudo element that is attached to thesummary
element and it’s basically impossible to listen to an event on a pseudo element.A possible work around would be to listen to clicks on the summary element then disabling the point-events for the entire element and enabling it back for the pseudo element, see this post.
If you just want to get the state of the details element (
open
/closed
), you can use thetoggle
event:Use Vue’s .stop modifier
Vue has event modifiers that account for this use case, and the
.stop
modifier should be what you need.This works for me:
https://codepen.io/MarsAndBack/pen/PoLYPZR