File tree 2 files changed +33
-0
lines changed
src/dashboard/Data/Browser
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ class Browser extends DashboardView {
121
121
this . closeEditRowDialog = this . closeEditRowDialog . bind ( this ) ;
122
122
this . handleShowAcl = this . handleShowAcl . bind ( this ) ;
123
123
this . onDialogToggle = this . onDialogToggle . bind ( this ) ;
124
+ this . abortAddRow = this . abortAddRow . bind ( this ) ;
124
125
}
125
126
126
127
componentWillMount ( ) {
@@ -294,6 +295,14 @@ class Browser extends DashboardView {
294
295
}
295
296
}
296
297
298
+ abortAddRow ( ) {
299
+ if ( this . state . newObject ) {
300
+ this . setState ( {
301
+ newObject : null
302
+ } ) ;
303
+ }
304
+ }
305
+
297
306
addRowWithModal ( ) {
298
307
this . addRow ( ) ;
299
308
this . selectRow ( undefined , true ) ;
@@ -1025,6 +1034,7 @@ class Browser extends DashboardView {
1025
1034
onCloneSelectedRows = { this . showCloneSelectedRowsDialog }
1026
1035
onEditSelectedRow = { this . showEditRowDialog }
1027
1036
onEditPermissions = { this . onDialogToggle }
1037
+ onAbortAddRow = { this . abortAddRow }
1028
1038
1029
1039
columns = { columns }
1030
1040
className = { className }
Original file line number Diff line number Diff line change @@ -138,6 +138,29 @@ export default class DataBrowser extends React.Component {
138
138
if ( this . props . disableKeyControls ) {
139
139
return ;
140
140
}
141
+ if (
142
+ this . state . editing &&
143
+ this . state . current &&
144
+ this . state . current . row === - 1 &&
145
+ this . props . newObject
146
+ ) {
147
+ // if user is editing new row and want to cancel editing cell
148
+ if ( e . keyCode === 27 ) {
149
+ this . setState ( {
150
+ editing : false
151
+ } ) ;
152
+ e . preventDefault ( ) ;
153
+ }
154
+ return ;
155
+ }
156
+ if ( ! this . state . editing && this . props . newObject ) {
157
+ // if user is not editing any row but there's new row
158
+ if ( e . keyCode === 27 ) {
159
+ this . props . onAbortAddRow ( ) ;
160
+ e . preventDefault ( ) ;
161
+ }
162
+ return ;
163
+ }
141
164
if ( this . state . editing ) {
142
165
switch ( e . keyCode ) {
143
166
case 27 : // ESC
You can’t perform that action at this time.
0 commit comments