25 Nov 2012 7:44 AM #1
can unselect text from combobox where allow blank is false
Internet Explorer 8
Windows 7 : 64 bit
If I create a combo box where "allow blank" is false, a blank entry is not available in the drop-down selection (as expected). However, if I type quickly enough, I can blank out text, tab out of cell, and the cell would be blank.
I was expecting that the combo box would revert back to the previous value. Especially since "Force Selection" is also true. Blank is not a selection, so it cannot be a "forced" selection (it isn't any selection).
In provided test code, select a value. Then do a select all of the text and do "delete" and then "tab" as quickly as possible. The combo box will be left w/out a selection.
comboBox.setAllowBlank(false); comboBox.setSelectOnFocus(true); comboBox.setEditable(true); comboBox.setTypeAhead(true); comboBox.setForceSelection(true); comboBox.setAutoValidate(false); comboBox.setMinChars(1); comboBox.setTypeAheadDelay(0); comboBox.setQueryDelay(0); comboBox.setTriggerAction(TriggerAction.ALL); comboBox.setValidateOnBlur(false);
25 Nov 2012 7:59 AM #2
if I type "b" and tab prior to the type ahead / force selection works, I can also get a blank entry.
A similar issue is that I want to be able to turn off "type ahead", but would like force selection to still apply causing the first item that matches what is typed to be selected (and fire the select event prior to blurring). Unfortunately, I have scenarios where user can leave combo box w/out the selection event firing.
I am looking into alternate ways to get my invariants to remain invariant, but right now I get into an invalid state, since the selection even does fire on one combo box as the user navigates to the next.
I have tried to add in onblur events, but at that time, if the user has partially typed something w/out forcing a selection (or with type ahead) the selected value is NULL.
I will be trying to create a more proper scenario on this issue and reporting it as a defect; provided I can express it better than in this response.
4 Dec 2012 8:56 AM #3
Does this solve your issue?
4 Dec 2012 9:06 AM #4
No, this still allows for a blank entry, it just says it isn't valid.
I want to prevent a blank entry, which is what I would expect with "allowBlank=false".
Also, we are not using your validation in our application, so I wouldn't want the validation icon and decorations to show, either. We want a combo-box that once a valid is entered, it cannot be undone.
We have combo boxes that affect the behavior of other combo boxes. Once we trigger a change in one combo box it triggers changes in the others. By making it not allow blanks, we don't have to worry about "resetting" the UI back to the initial state. There are also other usability issues to why we want allowBlank=false to prevent (and not just give a validation).
5 Dec 2012 7:33 AM #5
The allowBlank property isn't designed to say 'this field may under no conditions be blank' - that would result in (for example) un-clearable NumberField, TextField, etc, instead of reporting an issue to the user.
Typically, the setEditable method is used to restrict the use from entering any keys at all, but using the drop down instead, but it sounds as though you want to a) let them type whatever they want, then b) if the value doesn't match exactly to a value in the dropdown, restore the previous value to the combo? This is a little further from the default functionality of the ComboBox than can be built just by config options.
I might start with setEditable(false) and a key handler, and either invoke doQuery with each accepted key, or just select the first item in the store that matches the current input. Track and display inputs by directly modifying the contents of the ComboBox.getInputEl(), and use the provided text selection methods to manage which chars are selected. Alternatively, leave it editable, but .preventDefault() any key event which doesn't match existing items.
Another approach could be to list for valuechange/select/invalid, and replace the value with an earlier one. Here you may need to defer the setValue call, since it might be in the middle of a re-render, or about to perform one.