@@ -381,11 +381,12 @@ export default {
381381 },
382382
383383 /**
384- * The containing element for the menu popover
384+ * The containing element or selector for the tribute (menu popover)
385+ * Defaults to `body` element
385386 */
386387 menuContainer: {
387- type: Element ,
388- default : () => document . body ,
388+ type: [ String , Element , null ] ,
389+ default: null ,
389390 },
390391
391392 /**
@@ -601,11 +602,6 @@ export default {
601602
602603 // Update default value
603604 this .updateContent (this .model )
604-
605- // Tribute.js library ensures that `el.contentEditable = true` when attaching to element.
606- // This overwrites the template binding.
607- // Set the contenteditable attribute to actual value afterward
608- this .$refs .contenteditable .contentEditable = this .contenteditableAttributeValue
609605 },
610606
611607 beforeDestroy () {
@@ -722,15 +718,26 @@ export default {
722718 })
723719 }
724720
721+ // Resolve container for Tribute.js to be mounted to (default - ` null ` )
722+ const menuContainer = (typeof this.menuContainer === 'string')
723+ ? document.querySelector(this.menuContainer)
724+ : this.menuContainer
725+
725726 this.tribute = new Tribute({
726727 collection: tributesCollection,
727728 // FIXME: tributejs doesn't support allowSpaces as a collection option, only as a global one
728729 // Requires to fork a library to allow spaces only in the middle of mentions ('@' trigger)
729730 allowSpaces: false,
730731 // Where to inject the menu popup
731- menuContainer: this.menuContainer ,
732+ menuContainer,
732733 })
733734 this.tribute.attach(this.$refs.contenteditable)
735+
736+ // Tribute.js library v5.1.3 ensures that ` el .contentEditable = true ` when attaching to element.
737+ // This overwrites the template binding.
738+ // Set the contenteditable attribute to actual value afterward
739+ // TODO remove when Tribute.js library v5.1.4 is published on npm (or fork it)
740+ this.$refs.contenteditable.contentEditable = this.contenteditableAttributeValue
734741 },
735742
736743 getLink(item) {
0 commit comments