TagSpaces is an offline, open source, document manager with tagging support
feat: improving using enter for confirming some dialogs
Ilian Sapundshievd9ed8024e0f2
diff --git a/app/components/dialogs/AboutDialog.tsx b/app/components/dialogs/AboutDialog.tsxindex 95bd310b7..cf713f4f0 100644--- a/app/components/dialogs/AboutDialog.tsx+++ b/app/components/dialogs/AboutDialog.tsx@@ -81,13 +81,6 @@ const AboutDialog = (props: Props) => {}}- // function confirmFunction(event) {- // if (event.key === 'Enter' || event.keyCode === 13) {- // props.onClose();- // event.stopPropagation();- // }- // }-let versionInfo = 'Check for updates';if (newVersion && newVersion.length > 1) {if (updateAvailable) {diff --git a/app/components/dialogs/ColorPickerDialog.tsx b/app/components/dialogs/ColorPickerDialog.tsxindex eab9b149a..cf528f356 100644--- a/app/components/dialogs/ColorPickerDialog.tsx+++ b/app/components/dialogs/ColorPickerDialog.tsx@@ -97,6 +97,8 @@ const ColorPickerDialog = (props: Props) => {scroll="paper"onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/CreateDirectoryDialog.tsx b/app/components/dialogs/CreateDirectoryDialog.tsxindex 10156dfb7..5021bca54 100644--- a/app/components/dialogs/CreateDirectoryDialog.tsx+++ b/app/components/dialogs/CreateDirectoryDialog.tsx@@ -91,6 +91,8 @@ const CreateDirectoryDialog = (props: Props) => {scroll="paper"onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/CreateLocationDialog.tsx b/app/components/dialogs/CreateLocationDialog.tsxindex e84be6a26..bca5b5fa5 100644--- a/app/components/dialogs/CreateLocationDialog.tsx+++ b/app/components/dialogs/CreateLocationDialog.tsx@@ -264,7 +264,15 @@ class CreateLocationDialog extends React.Component<Props, State> {fullScreen={fullScreen}keepMountedscroll="paper"- // onKeyDown={confirmFunction}+ onKeyDown={event => {+ if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();+ this.onConfirm();+ } else if (event.key === 'Escape') {+ onClose();+ }+ }}><DialogTitle>{i18n.t('core:createLocationTitle')}</DialogTitle><DialogContent>diff --git a/app/components/dialogs/CreateTagGroupDialog.tsx b/app/components/dialogs/CreateTagGroupDialog.tsxindex 47b997373..cc66908ed 100644--- a/app/components/dialogs/CreateTagGroupDialog.tsx+++ b/app/components/dialogs/CreateTagGroupDialog.tsx@@ -158,6 +158,8 @@ class CreateTagGroupDialog extends React.Component<Props, State> {scroll="paper"onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();this.onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/CreateTagsDialog.tsx b/app/components/dialogs/CreateTagsDialog.tsxindex 640fbe00a..375052bfb 100644--- a/app/components/dialogs/CreateTagsDialog.tsx+++ b/app/components/dialogs/CreateTagsDialog.tsx@@ -90,6 +90,8 @@ class CreateTagsDialog extends React.Component<Props, State> {scroll="paper"onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();this.onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/EditEntryTagDialog.tsx b/app/components/dialogs/EditEntryTagDialog.tsxindex d159fbd7e..3a0600960 100644--- a/app/components/dialogs/EditEntryTagDialog.tsx+++ b/app/components/dialogs/EditEntryTagDialog.tsx@@ -184,6 +184,8 @@ const EditEntryTagDialog = (props: Props) => {onClose={onClose}onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/EditLocationDialog.tsx b/app/components/dialogs/EditLocationDialog.tsxindex 660b273e8..0e6db630b 100644--- a/app/components/dialogs/EditLocationDialog.tsx+++ b/app/components/dialogs/EditLocationDialog.tsx@@ -482,18 +482,21 @@ class EditLocationDialog extends React.Component<Props, State> {);render() {- const {- open,- // onClose,- fullScreen,- onCancel- } = this.props;+ const { open, onClose, fullScreen, onCancel } = this.props;return (<Dialogopen={open}onClose={onCancel}fullScreen={fullScreen}- // onEnterKey={(event) => onEnterKeyHandler(event, this.onConfirm)}+ onKeyDown={event => {+ if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();+ this.onConfirm();+ } else if (event.key === 'Escape') {+ onClose();+ }+ }}>{this.renderTitle()}{this.renderContent()}diff --git a/app/components/dialogs/EditTagDialog.tsx b/app/components/dialogs/EditTagDialog.tsxindex 0c62747ca..189c09884 100644--- a/app/components/dialogs/EditTagDialog.tsx+++ b/app/components/dialogs/EditTagDialog.tsx@@ -177,6 +177,8 @@ class EditTagDialog extends React.Component<Props, State> {scroll="paper"onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();this.onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/EditTagGroupDialog.tsx b/app/components/dialogs/EditTagGroupDialog.tsxindex 58652ebca..2bbf17005 100644--- a/app/components/dialogs/EditTagGroupDialog.tsx+++ b/app/components/dialogs/EditTagGroupDialog.tsx@@ -298,6 +298,8 @@ class EditTagGroupDialog extends React.Component<Props, State> {onClose={onClose}onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();this.onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/RenameDirectoryDialog.tsx b/app/components/dialogs/RenameDirectoryDialog.tsxindex b45ccab09..f2c466d5a 100644--- a/app/components/dialogs/RenameDirectoryDialog.tsx+++ b/app/components/dialogs/RenameDirectoryDialog.tsx@@ -106,6 +106,8 @@ class RenameDirectoryDialog extends React.Component<Props, State> {scroll="paper"onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();this.onConfirm();} else if (event.key === 'Escape') {onClose();diff --git a/app/components/dialogs/RenameFileDialog.tsx b/app/components/dialogs/RenameFileDialog.tsxindex 013c6c424..527beabda 100644--- a/app/components/dialogs/RenameFileDialog.tsx+++ b/app/components/dialogs/RenameFileDialog.tsx@@ -186,6 +186,8 @@ class RenameFileDialog extends React.Component<Props, State> {onClose={onClose}onKeyDown={event => {if (event.key === 'Enter' || event.keyCode === 13) {+ event.preventDefault();+ event.stopPropagation();this.onConfirm();} else if (event.key === 'Escape') {onClose();