dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.78k stars 229 forks source link

Remove elements from dragulaInput target box with custom dragulaOpts #143

Open f-meister opened 3 years ago

f-meister commented 3 years ago

Right now, I would like the dragula inputs to have a combination of behaviors for "replace = TRUE" and "replace = FALSE", where if the user selects an element from the source box, it will be copied over. The objective is to have multiple instances the source element in any of the target boxes, and there can be more than 1 item in each target box.

To achieve this, I've tried the following:

    dragulaInput(
      inputId = ns("dragvars"),
      sourceLabel = "Variables",
      targetsLabels = c("X", "Y", "Fill", "Color", "Size", "Group", "Facet", "FacetRow", "FacetCol"),
      targetsIds = c("xvar", "yvar", "fill", "color", "size", "group", "facet", "facet_row", "facet_col"),
      choiceValues = var_choices,
      choiceNames = badgeType(
        col_name = var_choices,
        col_type = col_type(source_data[, var_choices])
      ),
      dragulaOpts = list(copy = TRUE),
      status = "primary",
      badge = FALSE,
      width = "100%",
      height = "70px",
      replace = FALSE
    )

However, this causes the elements in the target boxes to be stuck and cannot be removed from the target box. Another effect it has is duplicating the elements in the source box if the user drags from target box to source box.

Hope you can help with a fix for this.

-Fabian