@@ -46,7 +46,7 @@ export default class GeoPointEditor extends React.Component {
46
46
}
47
47
48
48
handleKeyLatitude ( e ) {
49
- if ( e . keyCode === 13 ) {
49
+ if ( e . keyCode === 13 || e . keyCode === 44 ) {
50
50
this . refs . longitude . focus ( ) ;
51
51
this . refs . longitude . setSelectionRange ( 0 , String ( this . state . longitude ) . length ) ;
52
52
}
@@ -83,6 +83,34 @@ export default class GeoPointEditor extends React.Component {
83
83
render ( ) {
84
84
let onChange = ( target , e ) => {
85
85
let value = e . target . value ;
86
+
87
+ if ( ! validateNumeric ( value ) ) {
88
+ var values = value . split ( "," ) ;
89
+
90
+ if ( values . length == 2 ) {
91
+ values = values . map ( function ( val ) {
92
+ return val . trim ( ) ;
93
+ } ) ;
94
+
95
+ if ( values [ 0 ] . length > 0 && validateNumeric ( values [ 0 ] ) ) {
96
+
97
+ if ( values [ 1 ] . length <= 0 || ! validateNumeric ( values [ 1 ] ) ) {
98
+ this . setState ( { [ "latitude" ] : values [ 0 ] } ) ;
99
+ this . refs . longitude . focus ( ) ;
100
+ this . refs . longitude . setSelectionRange ( 0 , String ( this . state . longitude ) . length ) ;
101
+ return ;
102
+ }
103
+
104
+ if ( validateNumeric ( values [ 1 ] ) ) {
105
+ this . setState ( { [ "latitude" ] : values [ 0 ] } ) ;
106
+ this . setState ( { [ "longitude" ] : values [ 1 ] } ) ;
107
+ this . refs . longitude . focus ( ) ;
108
+ return ;
109
+ }
110
+ }
111
+ }
112
+ }
113
+
86
114
this . setState ( { [ target ] : validateNumeric ( value ) ? value : this . state [ target ] } ) ;
87
115
} ;
88
116
return (
0 commit comments