Skip to main content

Search and Top Navigation

#8150 open feature ()

Opened February 29, 2012 11:31PM UTC

Last modified November 05, 2012 09:55AM UTC

Selectable Stop Event Fires Multiple Times While Holding Ctrl

Reported by: Ariesto Owned by:
Priority: minor Milestone: 2.0.0
Component: ui.selectable Version: 1.8.18
Keywords: Cc:
Blocked by: Blocking:

To reproduce this enhancement:

Hold ctrl and click on Item 1, and Item 7. Then let control go. You will see the stop event fired twice instead of one time.

Currently the stop event triggers on click. This works with contiguous selection, but selectable is supposed to support Ctrl/ metakey holding as well. In cases where you hold the Ctrl key the stop event occurs multiple times, not once the Ctrl key is let go. In my mind this is counter-intuitive since I am looking for an event that signals the completion of the selection.

Half of the fix is to wrap the stop trigger in an 'if statement' to check if the ctrl key is pressed like so:

if (!event.metaKey && !event.ctrlKey) { this._trigger("stop", event)}

The second half is on .KeyUp then broadcast the event.

I haven't been able to figure out how to access the .Keyup event inside the selectable.js (I'm new to this).

Attachments (0)
Change History (5)

Changed March 01, 2012 06:02PM UTC by Ariesto comment:1

Here is the solution that works for me:

I add a new option: triggerOnce: false

Then I change the stop event trigger with the two if statements below:

        //Cases where the ctrl button is not pressed
        if (!event.metaKey && !event.ctrlKey) { this._trigger("stop", event);}

        //Cases where the ctrl button is pressed
        if (options.triggerOnce == false) {$(document).keyup(function() {self._trigger("stop", event); }); options.triggerOnce = true;}

In my local code I reset the triggerOnce and it works like a charm. I am applying the .keyup to the document because .keyup requires focus and I was having trouble finding the element.

I'm sure others will want to refactor/ probably have issue with changing the stop event logic. Also, logically you would change the start event to operate the same way, but in my case I don't need to so I have not.

Changed March 01, 2012 06:23PM UTC by Ariesto comment:2

I tried making a fork. Dunno how well it will work:

Changed June 26, 2012 01:24AM UTC by scottgonzalez comment:3

type: enhancementfeature

Changed October 11, 2012 02:53PM UTC by scottgonzalez comment:4


Changed November 05, 2012 09:55AM UTC by jzaefferer comment:5

status: newopen

Consider for redesign.