diff --git a/R/methods.R b/R/methods.R index c2fabe7..b5a0606 100644 --- a/R/methods.R +++ b/R/methods.R @@ -25,13 +25,15 @@ print.bucket_list <- function(x, ...){ # The names must be suffix values to allow for modules which use prefix values # https://github.com/rstudio/sortable/issues/100 as_rank_list_id <- function(id) { - paste0("rank-list-", id) + # paste0("rank-list-", id) + paste0(id, "-rank-list") } # TODO: in future, change the order of paste, to enable shiny modules # paste0(id, "-rank-list") as_bucket_list_id <- function(id) { - paste0("bucket-list-", id) + # paste0("bucket-list-", id) + paste0(id, "-bucket-list") } # TODO: in future, change the order of paste, to enable shiny modules # paste0(id, "-bucket-list") diff --git a/R/rank_list.R b/R/rank_list.R index 78a8c43..48a35a3 100644 --- a/R/rank_list.R +++ b/R/rank_list.R @@ -164,9 +164,15 @@ update_rank_list <- function(css_id, text = NULL, labels = NULL, if ( !is.null(labels) && length(labels) > 0) { labels <- as.character(tagList(as_label_tags(labels))) } - message <- dropNulls(list(id = inputId, text = text, labels = labels)) - session$sendInputMessage(inputId, message) + # include namespace in message + # to conveniently correct the nested input IDs + # of a rank-list widget inside rank_list_binding.js + message <- dropNulls(list(id = inputId, + text = text, + labels = labels, + namespace = session$ns(""))) + session$sendInputMessage(inputId, message) } diff --git a/inst/htmlwidgets/plugins/sortable-rstudio/rank_list_binding.js b/inst/htmlwidgets/plugins/sortable-rstudio/rank_list_binding.js index c20e384..153b2a8 100644 --- a/inst/htmlwidgets/plugins/sortable-rstudio/rank_list_binding.js +++ b/inst/htmlwidgets/plugins/sortable-rstudio/rank_list_binding.js @@ -22,7 +22,7 @@ $.extend(ranklistBinding, { } if (data.labels) { - const short_id = data.id.replace(/^rank-list-/, ""); + const short_id = data.namespace + data.id.replace(/-rank-list$/, ""); $('#' + short_id).html(data.labels); const label_ids = $('#' + short_id).children().map((idx, child) => { return $(child).attr("data-rank-id") || $.trim(child.innerHTML);