rstudio / sortable

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

sortable_js_capture_input does not fire on an empty "sortable" #32

Closed colearendt closed 5 years ago

colearendt commented 5 years ago

https://github.com/rstudio/sortable/blob/ef56c4c0ae2a7eef4063132c83f3a0f257abe568/R/sortable_js_capture_input.R#L14-L17

This is particularly troubling if/when a Shiny app's sortable input has been emptied. This message only goes back to the server side if/when there is at least one element in the list. (i.e. mapping over an empty array / no children means no function firing and no update to the server side).

Perhaps we could even make the callback configurable here (add a parameter "child_node_callback" or someting) that defaults to the current behavior.

EDIT: Although... this may just be a problem with observeEvent(input$my_input, {}). Yeah, because an empty list is getting sent back to R, which is what we expect. So it is just observeEvent not firing on the NULL that is confusing me.

colearendt commented 5 years ago

Yep, observe works fine. It is the NULL that throws observeEvent into silence 😅