Opened 6 years ago

Closed 5 years ago

#17796 closed defect (fixed)

Button: strips key information from click events

Reported by: cwgorman Owned by: Patrick Ruzand
Priority: undecided Milestone: 2.0
Component: Dijit - Form Version: 1.9.3
Keywords: Cc:
Blocked By: Blocking:

Description

When attaching a click handler to a dijit Button, the event object properties shiftKey, altKey, and ctrlKey are always false, regardless of whether the keys were actually pressed when the click occurred.

Here is a JSFiddle demonstrating the behavior: http://jsfiddle.net/y7JBm/2/

Hold Shift, Ctrl, or Alt and click either button. Note that the values returned are always false. For comparison, you can click on the div and see that the key information is correct.

Also, if one was to tab to the Button, hold Shift, and then press 'Enter', I would expect the resulting click event to have shiftKey=true despite not being a 'real' click.

Change History (2)

comment:1 Changed 6 years ago by bill

Milestone: tbd2.0
Owner: set to Patrick Ruzand
Status: newassigned
Summary: Button: dijit.form.Button strips key information from Click eventsButton: strips key information from click events

Although you would think this was trivial to fix, the problem is actually intrinsic to how Button is implemented with plain <div>/<span> DOMNodes and contains a hidden <input>. I'm talking about the code in _ButtonMixin that refires the click event:

__onClick: function(/*Event*/ e){
	// summary:
	//		Internal function to divert the real click onto the hidden INPUT that has a native default action associated with it
	// type:
	//		private
	e.stopPropagation();
	e.preventDefault();
	if(!this.disabled){
		// cannot use on.emit since button default actions won't occur
		this.valueNode.click(e);
	}
	return false;
},

We are passing the event object to this.valueNode.click(), but in reality that method doesn't take any parameters. Thus AFAICT there's no way to set shift/ctrl etc.

So anyway, this will be fixed in 2.0 when the Button widget is actually implemented as a <button>. I can't think of anyway to fix it beforehand.

comment:2 Changed 5 years ago by bill

Resolution: fixed
Status: assignedclosed

OK, so it's fixed in https://github.com/ibm-js/deliteful, so closing this ticket.

Note: See TracTickets for help on using tickets.