rstudio / sortable

R htmlwidget for Sortable.js
https://rstudio.github.io/sortable/
Other
130 stars 30 forks source link

onLoad fires too eagerly #36

Closed colearendt closed 5 years ago

colearendt commented 5 years ago

Related to #34

It seems that onLoad fires more eagerly than it should? It seems to fire twice on initialization and on every onSort, at least so far as I can tell. Is this the expected behavior?

rank_list(
        text = "List 1",
        input_id = session$ns("list_1"),
        labels = data_1(),
        options = sortable_options(
          group = "my-test",
          onLoad = htmlwidgets::JS("function(evt) { console.log('hello'); }"),
          onSort = htmlwidgets::JS("function(evt) { console.log('hello - sort'); }")
        )
      )

image

schloerke commented 5 years ago

No. It is not expected. I am only called it once.

I will look into this.

schloerke commented 5 years ago

@colearendt I can not reproduce given the rank_list code above. (It is behaving as expected.)

Can I have your full app?


My self contained test

rank_list(
  text = "List 1",
  input_id = "barret",
  labels = LETTERS[1:5],
  options = sortable_options(
    group = "my-test",
    onLoad = htmlwidgets::JS("function(evt) { console.log('calling onLoad', evt); }"),
    onSort = htmlwidgets::JS("function(evt) { console.log('calling onSort', evt); }")
  )
)
colearendt commented 5 years ago

Thanks for clarifying, and apologies for my shortsightedness here. I thought I had a grasp of some of the other reactive stuff I was doing, but this is my fault.

It makes sense that renderUI + changing the labels would contribute to a fully regenerated object, which is what I am experiencing here.