PDA

View Full Version : DatePicker select Today with SpaceBar shortcut key inserts a space on the field



fullinet
4 Jan 2012, 7:45 AM
- Detailed description of the problem
In DatePicker when you select the "today" date with the shortcut key (space bar) a space is inserted in the end of the text in the field, making the field marked as invalid.
You can test it in the Birthday DateField the Forms example in the "Explorer Demo" ( http://www.sencha.com/examples/explorer.html#forms )

- Possible solution
One possible working solution is change the onKeyPress(ComponentEvent ce) method of the KeyNav of the DatePicker class (line 801) from:


public void onKeyPress(ComponentEvent ce) {
// space bar pressed
if (ce.getKeyCode() == 32) {
selectToday();
}
}

to


public void onKeyPress(ComponentEvent ce) {
// space bar pressed
if (ce.getKeyCode() == 32) {
ce.stopEvent();
selectToday();
}
}


- GXT version
GXT 2.2.5 - GWT 2.4.0

- Host mode / web mode / both
Both modes

- Browser and version
IE 8, Firefox 9.0.1, Chrome 17.0.963.12 (dev), Opera 11.60

- Operating System
Windows XP SP3

sven
4 Jan 2012, 7:51 AM
The correct solution would be
Index: user/src/com/extjs/gxt/ui/client/widget/DatePicker.java===================================================================
--- user/src/com/extjs/gxt/ui/client/widget/DatePicker.java (revision 2473)
+++ user/src/com/extjs/gxt/ui/client/widget/DatePicker.java (working copy)
@@ -791,6 +791,7 @@
public void onKeyPress(ComponentEvent ce) {
// space bar pressed
if (ce.getKeyCode() == 32) {
+ ce.preventDefault();
selectToday();
}
}

fullinet
4 Jan 2012, 10:10 AM
Nice,
I used stopEvent() because I watched onKeyLeft() method.