Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ESC key binding #1695

Merged
merged 3 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Browser extends DashboardView {
this.closeEditRowDialog = this.closeEditRowDialog.bind(this);
this.handleShowAcl = this.handleShowAcl.bind(this);
this.onDialogToggle = this.onDialogToggle.bind(this);
this.abortAddRow = this.abortAddRow.bind(this);
}

componentWillMount() {
Expand Down Expand Up @@ -294,6 +295,14 @@ class Browser extends DashboardView {
}
}

abortAddRow(){
if(this.state.newObject){
this.setState({
newObject: null
});
}
}

addRowWithModal() {
this.addRow();
this.selectRow(undefined, true);
Expand Down Expand Up @@ -1013,6 +1022,7 @@ class Browser extends DashboardView {
onCloneSelectedRows={this.showCloneSelectedRowsDialog}
onEditSelectedRow={this.showEditRowDialog}
onEditPermissions={this.onDialogToggle}
onAbortAddRow={this.abortAddRow}

columns={columns}
className={className}
Expand Down
23 changes: 23 additions & 0 deletions src/dashboard/Data/Browser/DataBrowser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,29 @@ export default class DataBrowser extends React.Component {
if (this.props.disableKeyControls) {
return;
}
if (
this.state.editing &&
this.state.current &&
this.state.current.row === -1 &&
this.props.newObject
) {
// if user is editing new row and want to cancel editing cell
if (e.keyCode === 27) {
this.setState({
editing: false
});
e.preventDefault();
}
return;
}
if(!this.state.editing && this.props.newObject){
// if user is not editing any row but there's new row
if(e.keyCode === 27){
this.props.onAbortAddRow();
e.preventDefault();
}
return;
}
if (this.state.editing) {
switch (e.keyCode) {
case 27: // ESC
Expand Down