I encountered several issues with the ComboBox control that should be addressed. I can duplicate the behavior on the test site, so I do not believe it has anything to do with my code.
- If you type a period into the text box, the cursor moves to the beginning of the input control (IE 7, FF)
- The backspace key deletes all text to the right of the cursor, rather than one character to the left of the cursor (FF)
- The delete key deletes ALL characters to the right of the cursor, then inserts a period in the last position, then moves the cursor to the beginning of the input control (FF)
I was able to fix these by making the following updates (note: I only tested this in IE 7 & FF):
1. If the _textBoxKeyDownHandler is used (i.e. InternetExplorer, Safari, WebKit), then skip the _handleErasureKeys in the _onTextBoxKeyPress. I think you could also skip the _handleEnterKey and _handleArrowKey since these have already been accounted for in the keydown handler too.
2. In the FF keypress event, it sets the charCode to 46 when you press the period key, and the keyCode to 46 when you press the delete key. In the Sys.UI.DomEvent constructor, it assigns: this.charCode = e.charCode || e.keyCode. So in a keypress event handler, there is no way to differentiate between these 2 keys without looking at the rawEvent. I believe this is something MS should fix in the core AJAX code, but until then, I changed _handleErasureKeys from:
isDeleteKey = (code == 46);
to
isDeleteKey = (e.rawEvent.keyCode == 46);
3. In _onTextBoxKeyPress, move the call to _handleErasureKeys before the processing of the selectedText & suggestedText logic (I moved it right before the block w/ the comment: get info about the text and selection)
I also made 2 other changes to account for issues I was having when I created a combobox completely in javascript (including the DOM elements) instead of using the server control.
4. In the initializeOptionListItem function, IE was raising an error when setting the innerHTML property. This may have been something specific to how I was using the control, but I was able to get it to work by changing that line to:
liElement.appendChild(document.createTextNode('\u00a0'));
5. After disposing the combobox control, the mouse wheel would raise an error in FF, so I added the following to the clearHandlers function:
if (document.ajax__combobox_prototypes) {
Array.remove(document.ajax__combobox_prototypes, this);
}
Comments: This issue is fixed with release June 2012.
- If you type a period into the text box, the cursor moves to the beginning of the input control (IE 7, FF)
- The backspace key deletes all text to the right of the cursor, rather than one character to the left of the cursor (FF)
- The delete key deletes ALL characters to the right of the cursor, then inserts a period in the last position, then moves the cursor to the beginning of the input control (FF)
I was able to fix these by making the following updates (note: I only tested this in IE 7 & FF):
1. If the _textBoxKeyDownHandler is used (i.e. InternetExplorer, Safari, WebKit), then skip the _handleErasureKeys in the _onTextBoxKeyPress. I think you could also skip the _handleEnterKey and _handleArrowKey since these have already been accounted for in the keydown handler too.
2. In the FF keypress event, it sets the charCode to 46 when you press the period key, and the keyCode to 46 when you press the delete key. In the Sys.UI.DomEvent constructor, it assigns: this.charCode = e.charCode || e.keyCode. So in a keypress event handler, there is no way to differentiate between these 2 keys without looking at the rawEvent. I believe this is something MS should fix in the core AJAX code, but until then, I changed _handleErasureKeys from:
isDeleteKey = (code == 46);
to
isDeleteKey = (e.rawEvent.keyCode == 46);
3. In _onTextBoxKeyPress, move the call to _handleErasureKeys before the processing of the selectedText & suggestedText logic (I moved it right before the block w/ the comment: get info about the text and selection)
I also made 2 other changes to account for issues I was having when I created a combobox completely in javascript (including the DOM elements) instead of using the server control.
4. In the initializeOptionListItem function, IE was raising an error when setting the innerHTML property. This may have been something specific to how I was using the control, but I was able to get it to work by changing that line to:
liElement.appendChild(document.createTextNode('\u00a0'));
5. After disposing the combobox control, the mouse wheel would raise an error in FF, so I added the following to the clearHandlers function:
if (document.ajax__combobox_prototypes) {
Array.remove(document.ajax__combobox_prototypes, this);
}
Comments: This issue is fixed with release June 2012.