Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wishlish] Disable deselection of elements #1612

Open
ikegami opened this issue Aug 25, 2019 · 9 comments
Open

[Wishlish] Disable deselection of elements #1612

ikegami opened this issue Aug 25, 2019 · 9 comments
Labels
enhancement Quality of life changes to existing features MultiDrag Relating to the MultiDrag plugin

Comments

@ikegami
Copy link

ikegami commented Aug 25, 2019

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.

@owen-m1 owen-m1 added enhancement Quality of life changes to existing features MultiDrag Relating to the MultiDrag plugin labels Aug 30, 2019
@owen-m1
Copy link
Member

owen-m1 commented Aug 30, 2019

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

@ikegami
Copy link
Author

ikegami commented Aug 30, 2019

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);
         }
   )
);

@ikegami
Copy link
Author

ikegami commented Aug 30, 2019

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);

@owen-m1
Copy link
Member

owen-m1 commented Aug 30, 2019

@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).

@ikegami
Copy link
Author

ikegami commented Aug 30, 2019

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

@aurovrata
Copy link

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.

@aurovrata
Copy link

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();
});

@BrianKan714
Copy link

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,

@aurovrata
Copy link

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
Labels
enhancement Quality of life changes to existing features MultiDrag Relating to the MultiDrag plugin
Projects
None yet
Development

No branches or pull requests

4 participants