Skip to content

Commit

Permalink
Improve toast message shortcut on component deletion (ToolJet#4513)
Browse files Browse the repository at this point in the history
* Improve toast message shortcut

* Improved user agent check

Co-authored-by: Kavin Venkatachalam <[email protected]>

* Improved user agent check

Co-authored-by: Kavin Venkatachalam <[email protected]>
  • Loading branch information
3t8 and kavinvenkatachalam authored Oct 31, 2022
1 parent 904c919 commit 8908617
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions frontend/src/Editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,16 @@ class EditorComponent extends React.Component {
const selectedComponents = this.state?.selectedComponents;

removeSelectedComponent(newDefinition, selectedComponents);

toast('Selected components deleted! (⌘Z to undo)', {
icon: '🗑️',
});
const platform = navigator?.userAgentData?.platform || navigator?.platform || 'unknown';
if (platform.toLowerCase().indexOf('mac') > -1) {
toast('Selected components deleted! (⌘ + Z to undo)', {
icon: '🗑️',
});
} else {
toast('Selected components deleted! (ctrl + Z to undo)', {
icon: '🗑️',
});
}
this.appDefinitionChanged(newDefinition, {
skipAutoSave: this.isVersionReleased(),
});
Expand Down Expand Up @@ -613,9 +619,16 @@ class EditorComponent extends React.Component {
});

delete newDefinition.components[component.id];
toast('Component deleted! (⌘Z to undo)', {
icon: '🗑️',
});
const platform = navigator?.userAgentData?.platform || navigator?.platform || 'unknown';
if (platform.toLowerCase().indexOf('mac') > -1) {
toast('Component deleted! (⌘ + Z to undo)', {
icon: '🗑️',
});
} else {
toast('Component deleted! (ctrl + Z to undo)', {
icon: '🗑️',
});
}
this.appDefinitionChanged(newDefinition, {
skipAutoSave: this.isVersionReleased(),
});
Expand Down

0 comments on commit 8908617

Please sign in to comment.