From 50a04006165fbf387fc7c270ed45701c7f2a5d7c Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 6 Sep 2019 22:18:03 +0200 Subject: [PATCH] fix note type selection --- src/public/javascripts/services/link_map.js | 18 ++++++++++-------- src/public/javascripts/services/note_type.js | 6 +++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/public/javascripts/services/link_map.js b/src/public/javascripts/services/link_map.js index a09ee6bc6..354f8aa9c 100644 --- a/src/public/javascripts/services/link_map.js +++ b/src/public/javascripts/services/link_map.js @@ -203,16 +203,18 @@ export default class LinkMap { this.renderer.stop(); } - // delete all endpoints and connections - // this is done at this point (after async operations) to reduce flicker to the minimum - this.jsPlumbInstance.deleteEveryEndpoint(); + if (this.jsPlumbInstance) { + // delete all endpoints and connections + // this is done at this point (after async operations) to reduce flicker to the minimum + this.jsPlumbInstance.deleteEveryEndpoint(); - // without this we still end up with note boxes remaining in the canvas - this.$linkMapContainer.empty(); + // without this we still end up with note boxes remaining in the canvas + this.$linkMapContainer.empty(); - // reset zoom/pan - this.pzInstance.zoomAbs(0, 0, this.options.zoom); - this.pzInstance.moveTo(0, 0); + // reset zoom/pan + this.pzInstance.zoomAbs(0, 0, this.options.zoom); + this.pzInstance.moveTo(0, 0); + } } initJsPlumbInstance() { diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.js index 993728757..bb9f6d035 100644 --- a/src/public/javascripts/services/note_type.js +++ b/src/public/javascripts/services/note_type.js @@ -73,7 +73,11 @@ export default class NoteTypeContext { .attr("data-mime-type", mimeType.mime) .append(' ') .append($('').text(mimeType.title)) - .click(e => this.save('code', $(e.target).attr('data-mime-type'))); + .click(e => { + const $link = $(e.target).closest('.dropdown-item'); + + this.save('code', $link.attr('data-mime-type')) + }); if (this.ctx.note.type === 'code' && this.ctx.note.mime === mimeType.mime) { $mimeLink.addClass("selected");