TagSpaces is an offline, open source, document manager with tagging support
Tsn497 txt file edit bugfix (#1242)
Stanimir4e310514d1c0
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex 284e2bf46..4ff7dcd3d 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -410,7 +410,7 @@ const EntryContainer = (props: Props) => {const reloadDocument = () => {if (openedFile) {- if (openedFile.changed) {+ if (openedFile.editMode && openedFile.changed) {setSaveBeforeReloadConfirmDialogOpened(true);} else {props.updateOpenedFile(openedFile.path, {@@ -510,7 +510,8 @@ const EntryContainer = (props: Props) => {const editFile = () => {props.updateOpenedFile(openedFile.path, {...openedFile,- editMode: true+ editMode: true,+ shouldReload: undefined});};diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex b4410f27e..77631edaf 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -303,11 +303,7 @@ const EntryProperties = (props: Props) => {setEditName(undefined);return;}- if (editName !== undefined) {- setEditName(undefined);- } else {- setEditName(fileName);- }+ setEditName(fileName);};const deactivateEditNameField = () => {diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsxindex 5f00a188a..9ab9a7e1b 100644--- a/app/components/dialogs/AddRemoveTagsDialog.tsx+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx@@ -60,10 +60,21 @@ class AddRemoveTagsDialog extends React.Component<Props, State> {isConfirmDialogOpened: false};- handleChange = (name, value) => {- this.setState({- newlyAddedTags: value- });+ handleChange = (name: string, value: Array<Tag>, action: string) => {+ if (action === 'remove-value') {+ const tagsToRemove: Array<string> = value.map(tag => tag.title);+ // eslint-disable-next-line react/no-access-state-in-setstate+ const newlyAddedTags = this.state.newlyAddedTags.filter(+ tag => !tagsToRemove.includes(tag.title)+ );+ this.setState({+ newlyAddedTags+ });+ } else {+ this.setState({+ newlyAddedTags: value+ });+ }};onClose = (clearSelection?: boolean) => {diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 8b0862cae..4aa6f5de1 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -1388,9 +1388,7 @@ export const actions = {if (fsEntryMeta.editMode !== undefined) {entryForOpening.editMode = fsEntryMeta.editMode;}- if (fsEntryMeta.shouldReload !== undefined) {- entryForOpening.shouldReload = fsEntryMeta.shouldReload;- }+ entryForOpening.shouldReload = fsEntryMeta.shouldReload;if (fsEntryMeta.color) {entryForOpening.color = fsEntryMeta.color;}