Ticket #4293 (closed bug: fixed)

Opened 6 years ago

Last modified 4 years ago

Ctrl + Click on selected list item does not deselect

Reported by: managingmeals Owned by:
Priority: major Milestone: 1.8.2
Component: ui.selectable Version: 1.7
Keywords: Cc:
Blocking: Blocked by:

Description

You can use ctrl and a mouse click to select items that are non- adjacent. However if you try to click a selected item while holding control it does not deselect it. This is how one would expect it to function as this is how windows explorer (and i think its the same on mac).

A sample is windows explorer. Make your selection either with ctrl to select individual items or a lasso for multiple items, or a combination of both. After you do that you can deselect whatever you want and keep the rest selected by holding ctrl and and click a selected item.

Maybe this is already possible and im not seeing it or its a bug? I don't see any documentation of it, or a sample of it.

Please add this feature, if its not already added.

Thanks

Change History

comment:1 Changed 6 years ago by rdworth

  • Milestone changed from TBD to 1.8

comment:2 Changed 6 years ago by Cloudream

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from 1.8 to TBD

fixed in new selectable

comment:3 Changed 5 years ago by jjones

I'm using the latest version of jQuery along with the most recent version of the UI, and I'm not seeing an resolution to this issue.

I've tried it myself to no avail, and it also doesn't even work on your own demo page found here:  http://jqueryui.com/demos/selectable/

This is a frustrating issue when you have a large list of items that users are selecting from, as if they happen to select one they didn't mean to, they'll have to start all over from the beginning to deselect the undesired item.

comment:4 Changed 5 years ago by rdworth

  • Status changed from closed to reopened
  • Resolution fixed deleted

I don't know why this issue was closed as the new selectable refactor is still in development. See  http://wiki.jqueryui.com/Selectable

comment:5 follow-up: ↓ 6 Changed 4 years ago by jaysoo

I made a small change to _mouseStart function to get this to work as described using the metaKey (Ctrl/Cmd).

My fork:  http://github.com/jaysoo/jquery-ui/blob/df06075a331e47ac85f63c3f47a15d5df5f399bf/ui/jquery.ui.selectable.js

this.selectees.filter('.ui-selected').each(function() {
	var selectee = $.data(this, "selectable-item");
	selectee.startselected = true;
	if (!event.metaKey) {
		selectee.$element.removeClass('ui-selected');
		selectee.selected = false;
		selectee.$element.addClass('ui-unselecting');
		selectee.unselecting = true;
		// selectable UNSELECTING callback
		self._trigger("unselecting", event, {
			unselecting: selectee.element
		});
	}
});

comment:6 in reply to: ↑ 5 ; follow-up: ↓ 7 Changed 4 years ago by rdworth

Replying to jaysoo:

I made a small change to _mouseStart function to get this to work as described using the metaKey (Ctrl/Cmd).

My fork:  http://github.com/jaysoo/jquery-ui/blob/df06075a331e47ac85f63c3f47a15d5df5f399bf/ui/jquery.ui.selectable.js

this.selectees.filter('.ui-selected').each(function() {
	var selectee = $.data(this, "selectable-item");
	selectee.startselected = true;
	if (!event.metaKey) {
		selectee.$element.removeClass('ui-selected');
		selectee.selected = false;
		selectee.$element.addClass('ui-unselecting');
		selectee.unselecting = true;
		// selectable UNSELECTING callback
		self._trigger("unselecting", event, {
			unselecting: selectee.element
		});
	}
});

Commented on  GitHub "When unselecting is triggered, the property key needs to be 'unselecting' not 'selecting'. Compare lines 116, 202, 215."

comment:7 in reply to: ↑ 6 Changed 4 years ago by jaysoo

Replying to rdworth:

Commented on  GitHub "When unselecting is triggered, the property key needs to be 'unselecting' not 'selecting'. Compare lines 116, 202, 215."

My bad, here's the new commit:  http://github.com/jaysoo/jquery-ui/blob/13238fa835084e88aa10a7442db9f9214a67c86b/ui/jquery.ui.selectable.js

$(event.target).parents().andSelf().each(function() {
	var selectee = $.data(this, "selectable-item");
	if (selectee) {
		var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected');
		selectee.$element
			.removeClass(doSelect ? "ui-unselecting" : "ui-selected")
			.addClass(doSelect ? "ui-selecting" : "ui-unselecting");
		selectee.unselecting = !doSelect;
		selectee.selecting = doSelect;
		selectee.selected = doSelect;
		// selectable (UN)SELECTING callback
		if (doSelect) {
			self._trigger("selecting", event, {
				selecting: selectee.element
			});
		} else {
			self._trigger("unselecting", event, {
				unselecting: selectee.element
			});
		}
		return false;
	}
});

comment:8 Changed 4 years ago by rdworth

  • Status changed from reopened to closed
  • Resolution set to fixed

Fixed in  5b4c04a and  e780583

Thanks jaysoo!

comment:9 Changed 4 years ago by rdworth

  • Milestone changed from TBD to 1.8.2
Note: See TracTickets for help on using tickets.