Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#8004 closed enhancement (fixed)

Enhance FilteringSelect to provide a drop in replacement for a plain old select box

Reported by: ptwobrussell Owned by:
Priority: high Milestone: 1.3
Component: Dijit - Form Version: 1.2.0
Keywords: Cc: dante@…
Blocked By: Blocking:

Description

I feel strongly that there should be a drop-in dijit that provides the exact functionality of a select element - basically, a FilteringSelect? but without the ability for the caret to take the focus in the what's currently the editable area of FilteringSelect?. (Another way to think of it is for it to be a DropDownButton? but offer "hidden" values in addition to the displayed values.)

I gave it a little bit of thought and came up with the following patch, which would enhance FilteringSelect? to provide this kind of functionality. Plus, it would offer this "read only" kind of behavior to anything else that uses the ComboBoxMixIn?.

If it's not _the_ patch to get this done, I'd still like to engage a discussion about this topic because it seems to me that the omission of a "dijitized select element" is a hole we should fill. Maybe there's a backstory about why we didn't do this yet?

Anyway, here's something to get a discussion started:

Index: ComboBox.js
===================================================================
--- ComboBox.js	(revision 15563)
+++ ComboBox.js	(working copy)
@@ -89,6 +89,10 @@
 		//		Defaults to true.
 		hasDownArrow:true,
 
+        // editable: Boolean
+        //      Set this to false is you want to prevent the text part of the control from receiving the caret
+        editable : true,
+
 		templatePath: dojo.moduleUrl("dijit.form", "templates/ComboBox.html"),
 
 		baseClass:"dijitComboBox",
@@ -632,6 +636,8 @@
 					}
 				}
 			}
+
+            this.editable = this.editable ? "" : "disabled"; //if not editable, prevent the cursor from even entering the input area
 		},
 		
 		_postCreate:function(){

Index: templates/ComboBox.html
===================================================================
--- templates/ComboBox.html	(revision 15563)
+++ templates/ComboBox.html	(working copy)
@@ -12,7 +12,7 @@
 		><div class="dijitReset dijitValidationIconText">&Chi;</div
 		><div class="dijitReset dijitInputField"
 			><input type="text" autocomplete="off" name="${name}" class='dijitReset'
-			dojoAttachEvent="onkeypress:_onKeyPress, onfocus:_update, compositionend"
+            dojoAttachEvent="onkeypress:_onKeyPress, onfocus:_update, compositionend" ${editable}
 			dojoAttachPoint="textbox,focusNode" waiRole="textbox" waiState="haspopup-true,autocomplete-list"
 		/></div
 	></div

Change History (5)

comment:1 Changed 11 years ago by bill

Sounds like you want the already existing DropDownSelect widget?

http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/form/tests/test_DropDownSelect.html

comment:2 Changed 11 years ago by ptwobrussell

For my situation, I think the DropDownSelectWidget? would work fine. A few things:

  • I had no idea it was even in there? We should think about a way to "advertise" dojox.form so that if someone doesn't find what they want in Dijit it's more intuitive for them to look in there. Maybe something as simple as a "See also" kind of tag in the documentation or a README or something. I'm sure this is documented somewhere, but I bet we'd both agree that it's harder to find than "just being obvious"
  • Even though this works for me, doesn't it seem odd that a nice looking (themed) "plain old select" isn't part of Dijit from a philosophical sense? I mean, to me, that's where I would have naturally looked so my previous point becomes moot if this is the case. Then there are the "guarantees" about a11y that someone might want. I haven't looked at the source for the dojox.form.DropDownSelect? yet so maybe it already is

comment:3 Changed 11 years ago by bill

Resolution: fixed
Status: newclosed

I agree about the documentation. I added links to http://docs.dojocampus.org/dijit/form and http://docs.dojocampus.org/dijit/form/FilteringSelect.

As for moving the DropDownSelect widget into dijit, I agree that it should be there and plan to move it in the near future, maybe for 1.4.

comment:4 Changed 10 years ago by Adam Peller

Milestone: tbd1.3

batch move of tickets marked 'tbd' fixed in the 1.3 timeframe

comment:5 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.