2π
β
The issue is the li
is always running its click event handler even when you click on a button so selected
will always be reassigned to the current product.
To fix it, do one of the fllowing:
-
Replace
@click
with@click.stop
on each of the buttons to prevent the event from propagating up to theli
. -
remove the
@click="selected = p"
from theli
and add it to the firstspan
. This way the handler will only be run when the form is not present.
π€David Weldon
Source:stackexchange.com