Debug help — my plugin is breaking the Select-to-Reply-with-Quote feature

AI-generated summary

The user alxndr is facing an issue with their Discourse plugin that inadvertently disables the “quote selected text” feature and keyboard shortcut. The plugin loads third-party JavaScript dependencies (tippy and Popper) using loadScript from discourse/lib/load-script. The user suspects that the way these dependencies are loaded might be causing the issue and is seeking help to either find a better way to load JavaScript assets selectively or if they should include the assets on all topic pages instead. They have provided a link to the plugin’s GitHub repository and notes about the bug for reference.

Hoping someone can help me narrow down this issue — I created a plugin but it inadvertently disables the “quote selected text” popup & keyboard shortcut.

When the plugin is enabled, selecting text in a post no longer shows the “quote reply for highlighted text” feature — such that the PostTextSelectionToolbar popup doesn’t appear, pressing q doesn’t work, and clicking the Reply button starts a reply but not including the quote of selected text.

My hunch is that it’s related to how I’m loading third-party JS dependencies? I’m using the JavaScript loadScript from discourse/lib/load-script to load tippy and its dependency Popper from unpkg.com… Is there a better way to selectively load JS assets? (Or am I better off just including those assets on e.g. all topic pages and not trying to selectively load them?)

Here are my notes about about this bug. Any & all help is greatly appreciated!