Opened 7 years ago

Closed 7 years ago

#16743 closed defect (fixed)

Space breaks new type-ahead feature of Select control

Reported by: Bob Tarling Owned by: Douglas Hays
Priority: undecided Milestone: 1.9
Component: Dijit - Form Version: 1.9.0a1
Keywords: Cc:
Blocked By: #16754 Blocking:

Description

Related to #16589

I just noticed this when testing from your daily snapshot tests at http://archive.dojotoolkit.org/nightly/checkout/dijit/tests/form/test_Select.html

Try tabbing into the LongLists? fields and then type without opening the dropdown.

Most items work fine but then try "new y" to select New York

The space character breaks the type ahead behaviour and instead of changing the selection it opens the dropdown.

If the dropdown is open the problem is in the reverse. Space is ignored regarding type-ahead and the dropdown closes.

Some may still want to keep the feature where space opens/closes the dropdown so anything resolving this would have to be intelligent and know if type-ahead is in progress before knowing what to do with a space press.

Personally though I'd like to see space as a valid item (ie a selectable blank row in a picklist). In that case I'd expect a space would select that item. I think I saw some defect report suggesting this will change for Dojo 2.

I note also that richtext does not work and I would of course expect this. It may be worth making some comment in the documentation to that effect though. Later this might be managed by a new optional typeahead attribute that could be scanned instead of the actual label.

Attachments (2)

16743.patch (8.9 KB) - added by Douglas Hays 7 years ago.
proposed fix
16743_2.patch (9.2 KB) - added by Douglas Hays 7 years ago.
revised patch with preventDefault() and on.emit faux keypress

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by Douglas Hays

Blocked By: 16754 added

comment:2 Changed 7 years ago by bill

From a code perspective there are two bugs listed in this ticket.

The first issue is about hitting the SPACE key while focused on the Select widget itself, rather than the dropdown. _HasDropDown has code to ignore the SPACE character:

}else if(!this._opened &&
	(e.keyCode == keys.DOWN_ARROW ||
		( (e.keyCode == keys.ENTER || e.keyCode == keys.SPACE) &&
			//ignore enter and space if the event is for a text input
			((target.tagName || "").toLowerCase() !== 'input' ||

However, it only activates when this.focusNode is an <input>, so it won't activate for Select.

You could add a toggleOnSpace property to _HasDropDown to explicitly control the behavior. Alternately, if _KeyNavMixin's searching code is running before the above code in _HasDropDown, then _KeyNavMixin's could call evt.stopImmediatePropagation().


The other problem listed in this ticket is about when the drop down is open, and that actually affects drop down menus in general, not just Select's drop down menu. For example, on a typical "File" menu, searching for "Save As..." on a menu without single letter accessKeys defined will navigate to the "Save" menu item and select it. So it's really a problem with #16262.

I'm a little nervous about just disabling SPACE key for selecting menu items completely though. Perhaps it should only be disabled if a keyboard search is underway, i.e. if the user typed some normal characters first?

Last edited 7 years ago by bill (previous) (diff)

Changed 7 years ago by Douglas Hays

Attachment: 16743.patch added

proposed fix

comment:3 Changed 7 years ago by Douglas Hays

Milestone: tbd1.9
Status: newassigned

The attached patch needs review and testing to make sure Menu (et al) isn't broken.

comment:4 Changed 7 years ago by bill

The new tests you added to robot/Menu_a11y and form/robot/Select are failing for me. Tested on IE8.

comment:5 Changed 7 years ago by Douglas Hays

stopImmediatePropagation is broken on IE8

Changed 7 years ago by Douglas Hays

Attachment: 16743_2.patch added

revised patch with preventDefault() and on.emit faux keypress

comment:6 Changed 7 years ago by Douglas Hays

On older IE, the default scrolling action for the SPACE key occurs on keydown of the Select domNode even if stopPropagation() is called, even though it should be the default action after bubbling up to a parent node (probably BODY). So now I'm calling preventDefault() to stop the scrolling bu then this cancels the keypress as well which is where the searching occurs. So I emit a fake keypress instead.

comment:7 Changed 7 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

In [30751]:

Fixes #16743. If a search is already in progress, stop SPACE on keydown and process in keypress.

Note: See TracTickets for help on using tickets.