The culprit lies in the javascript code for the input binding. We use 2 places to update the element and on top of it we use both data('val') and .val() which are 2 different slots. The order in which shiny runs through the javascript code is as follows:
subscribe here we set data('val') to a new value (1 on first click)
getValue is called then, this function however returns val() which is still zero. shiny does not fire on a zero, so nothing happens.
Eventually, the click event is called where we change val() (this explains why the button works from second clicks onwards)
Issue
You need to hit an
bulmaActionButton
twice to get it fired.Reprex
Reason
The culprit lies in the javascript code for the input binding. We use 2 places to update the element and on top of it we use both
data('val')
and.val()
which are 2 different slots. The order in whichshiny
runs through the javascript code is as follows:subscribe
here we setdata('val')
to a new value (1 on first click)getValue
is called then, this function however returnsval()
which is still zero.shiny
does not fire on a zero, so nothing happens.val()
(this explains why the button works from second clicks onwards)https://github.com/RinteRface/shinybulma/blob/1389ddd15e7975ccbe9b9631cd16adbe89e59160/inst/js-0.7.2/bulma-button-js.js#L13-L24
Remedy
Remove the unnecessary
click
event and use the same slot throughout the binding (data('val')
for instance, inline withactionButton
fromshiny
itself:https://github.com/rstudio/shiny/blob/23dbb0b41cc948d25519e78b604413c9bb49cc92/srcjs/input_binding_actionbutton.js#L15-L26
I will create a PR.