@@ -124,22 +124,28 @@ const DataGridOverlayEditor: React.FunctionComponent<DataGridOverlayEditorProps>
124
124
const onKeyDown = React . useCallback (
125
125
async ( event : React . KeyboardEvent ) => {
126
126
let save = false ;
127
- if ( event . key === "Escape" ) {
128
- event . stopPropagation ( ) ;
129
- event . preventDefault ( ) ;
130
- customMotion . current = [ 0 , 0 ] ;
131
- } else if ( event . key === "Enter" && ! event . shiftKey ) {
132
- event . stopPropagation ( ) ;
133
- event . preventDefault ( ) ;
134
- customMotion . current = [ 0 , 1 ] ;
135
- save = true ;
136
- } else if ( event . key === "Tab" ) {
137
- event . stopPropagation ( ) ;
138
- event . preventDefault ( ) ;
139
- customMotion . current = [ event . shiftKey ? - 1 : 1 , 0 ] ;
140
- save = true ;
127
+ switch ( event . key ) {
128
+ case "Escape" : {
129
+ event . stopPropagation ( ) ;
130
+ event . preventDefault ( ) ;
131
+ customMotion . current = [ 0 , 0 ] ;
132
+ break ;
133
+ }
134
+ case "Enter" : {
135
+ event . stopPropagation ( ) ;
136
+ event . preventDefault ( ) ;
137
+ customMotion . current = [ 0 , event . shiftKey ? - 1 : 1 ] ;
138
+ save = true ;
139
+ break ;
140
+ }
141
+ case "Tab" : {
142
+ event . stopPropagation ( ) ;
143
+ event . preventDefault ( ) ;
144
+ customMotion . current = [ event . shiftKey ? - 1 : 1 , 0 ] ;
145
+ save = true ;
146
+ break ;
147
+ }
141
148
}
142
-
143
149
window . setTimeout ( ( ) => {
144
150
if ( ! finished . current && customMotion . current !== undefined ) {
145
151
onFinishEditing ( save ? tempValue : undefined , customMotion . current ) ;
0 commit comments