Skip to content

[Wishlish] Disable deselection of elements #1612

Open

Description

@ikegami

Hi! Could you please add an option to the MultiDrag plugin that disables deselecting of objects (i.e. avoids calling _deselectMultiDrag). It would be nice to have buttons that interact with the selected objects.

Activity

  1. added
    enhancementQuality of life changes to existing features
    MultiDragRelating to the MultiDrag plugin
    on Aug 30, 2019
  2. owen-m1 commented on Aug 30, 2019

    @owen-m1
    Member

    Perhaps there can be a deselectZone HTMLElement option that, if clicked, will deselect all elements in that sortable.

  3. ikegami commented on Aug 30, 2019

    @ikegami
    Author

    Perhaps there can be a deselectZone HTMLElement option that, if clicked, will deselect all elements in that sortable.

    I'm not sure how that pertains to what I suggested?

    Note that what you suggest is already trivially easy to produce:

    $button.click(
       (evt) => {
          $('> .sortable-selected', $sortable).each(
             (i, child) => {
                Sortable.utils.deselect(child);
             }
       )
    );
    
  4. ikegami commented on Aug 30, 2019

    @ikegami
    Author

    Right now, I'm using the following hack to achieve the requested enhancement:

    // Prevent deselection on external click.
    // HACK
    let deselectMultiDrag = sortable.multiDrag._deselectMultiDrag;
    document.removeEventListener('pointerup', deselectMultiDrag, false);
    document.removeEventListener('mouseup',   deselectMultiDrag, false);
    document.removeEventListener('touchend',  deselectMultiDrag, false);
    
  5. owen-m1 commented on Aug 30, 2019

    @owen-m1
    Member

    @ikegami It does pertain to what you suggest because the deselectZone option would be the document by default, and then when it is changed to another element, the multi drag elements would only get deselected when that element is clicked (as opposed to clicking anywhere on the document).

  6. ikegami commented on Aug 30, 2019

    @ikegami
    Author

    ah, I see what you mean. That would indeed be a suitable interface.

  7. aurovrata commented on Sep 21, 2019

    @aurovrata

    has this deselectZone been implemented?

    Another possible solution would be to add a class such as multidrag-click-ignore (or a data- attribute) to elements within the document that ought to be ignored when a click even is registered coming from them.

  8. aurovrata commented on Sep 21, 2019

    @aurovrata

    my current solution to this issue is to stop the event propagation on the specific element I wish to interact with without deselecting the items,

    $(element).on('pointerup mouseup touchend', function(event){
      event.stopPropagation();
    });
    
  9. BrianKan714 commented on Sep 25, 2019

    @BrianKan714

    But it seems it still cannot stop deselection while clicking on scrollBar
    Is it possible to make the feature of deselecting option while clicking empty space as one of config options. If true, deselect the multi drag option, otherwise no reaction,

  10. aurovrata commented on Sep 25, 2019

    @aurovrata

    likely you are not catching the event on the right element. You'll need to inspect your scroll bar and check which element is firing the event. It is possible there are more than one. You could bind an event callback on the document itself to see where your event is coming from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MultiDragRelating to the MultiDrag pluginenhancementQuality of life changes to existing features

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions