Skip to content

Commit

Permalink
fix: Make sure to always update card description when navigating awayfix
Browse files Browse the repository at this point in the history
fix #5254
fix #2705

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Nov 13, 2023
1 parent ffe8aa5 commit f8f81af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/card/CardSidebarTabDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ export default {
this.initialize()
},
methods: {
descriptionChanged(newDesc) {
this.$store.dispatch('updateCardDesc', { ...this.card, description: newDesc })
async descriptionChanged(newDesc) {
if (newDesc === this.copiedCard.description) {
return
}
this.copiedCard.description = newDesc
},
async initialize() {
Expand Down
20 changes: 17 additions & 3 deletions src/components/card/Description.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,26 @@ export default {
mounted() {
this.setupEditor()
},
beforeDestroy() {
this?.editor?.destroy()
async beforeDestroy() {
await this.destroyEditor()
},
methods: {
async setupEditor() {
this?.editor?.destroy()
await this.destroyEditor()
this.descriptionLastEdit = 0
this.description = this.card.description
this.editor = await window.OCA.Text.createEditor({
el: this.$refs.editor,
content: this.card.description,
readOnly: !this.canEdit,
onLoaded: () => {
this.descriptionLastEdit = 0
},
onUpdate: ({ markdown }) => {
if (this.description === markdown) {
this.descriptionLastEdit = 0
return
}
this.description = markdown
this.updateDescription()
},
Expand All @@ -206,6 +215,10 @@ export default {
})
},
async destroyEditor() {
await this.saveDescription()
this?.editor?.destroy()
},
addKeyListeners() {
this.$refs.markdownEditor.easymde.codemirror.on('keydown', (a, b) => {
if (this.keyExitState === 0 && (b.key === 'Meta' || b.key === 'Alt')) {
Expand Down Expand Up @@ -286,6 +299,7 @@ export default {
return
}
this.descriptionSaving = true
await this.$store.dispatch('updateCardDesc', { ...this.card, description: this.description })
this.$emit('change', this.description)
this.descriptionLastEdit = 0
this.descriptionSaving = false
Expand Down

0 comments on commit f8f81af

Please sign in to comment.