Issue #3392Opened April 7, 2021by rywilson280 reactions

FEAT: Allow dynamic droppable configuration using a function

Question

I have a requirement where I cannot use selectors to determine if an element is droppable. For example:

image

The "child" component must be within a "parent" component, however if the child component contains a ref attribute it can only be dragged into other parent containers that match the same ref value as the current parent. Given the above markup, the child component can be dropped into the last container but not the container with the ref of 5678. However the second child element could be dropped into any of the parent components.

Code SnippetTEXT
This would easily be accomplished if droppable would allow a function:
        droppable: (src, target) => {
          //some logic
          return true;
        }, 

This would require a fairly simple change to the Sorter:

    // Check if the target could accept the source
    let droppable = trgModel.get('droppable');
    if (typeof droppable === 'function') {
      let res = droppable(src, trg);
      result.droppable = res;
      result.dropInfo = res;
      droppable = res;
    } else {
     //existing logic

Answers (2)

rywilson28April 21, 20210 reactions

@artf do have any questions regarding this feature or the approach taken in the PR?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.