File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
src/dashboard/Data/Browser Expand file tree Collapse file tree 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 {
121121 this . closeEditRowDialog = this . closeEditRowDialog . bind ( this ) ;
122122 this . handleShowAcl = this . handleShowAcl . bind ( this ) ;
123123 this . onDialogToggle = this . onDialogToggle . bind ( this ) ;
124+ this . abortAddRow = this . abortAddRow . bind ( this ) ;
124125 }
125126
126127 componentWillMount ( ) {
@@ -294,6 +295,14 @@ class Browser extends DashboardView {
294295 }
295296 }
296297
298+ abortAddRow ( ) {
299+ if ( this . state . newObject ) {
300+ this . setState ( {
301+ newObject : null
302+ } ) ;
303+ }
304+ }
305+
297306 addRowWithModal ( ) {
298307 this . addRow ( ) ;
299308 this . selectRow ( undefined , true ) ;
@@ -1025,6 +1034,7 @@ class Browser extends DashboardView {
10251034 onCloneSelectedRows = { this . showCloneSelectedRowsDialog }
10261035 onEditSelectedRow = { this . showEditRowDialog }
10271036 onEditPermissions = { this . onDialogToggle }
1037+ onAbortAddRow = { this . abortAddRow }
10281038
10291039 columns = { columns }
10301040 className = { className }
Original file line number Diff line number Diff line change @@ -138,6 +138,29 @@ export default class DataBrowser extends React.Component {
138138 if ( this . props . disableKeyControls ) {
139139 return ;
140140 }
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+ }
141164 if ( this . state . editing ) {
142165 switch ( e . keyCode ) {
143166 case 27 : // ESC
You can’t perform that action at this time.
0 commit comments