If you flag a post, after the flag styling is applied, selecting text doesn't bring up the quote button.
The same behavior happens when unflagging. The quote button appears on page load, but after the flag is dismissed and the default styling is restored, the quote button doesn't appear again.
After a page reload or moving the post out of the loaded page range and back in, it works again.
Steps to Reproduce
Access any post that is not flagged
Select Flag in the post action dropdown, choose any reason
Wait for the flag style and reason to be rendered around the post
Quote feature no longer works on that post content
I suspect Mithril re-uses the DOM nodes instead of shifting them, which causes the jQuery object in Mentions to now point to the post header instead.
We should maybe introduce keyed vdom nodes to prevent the DIVs from being re-purposed by Mithril in that area. But this might break backward compatibility if any extension inserts a node without a key.
Additional Context
Observed first on Discuss while approving posts flagged by Approval extension. But it's not actually related to Approval.
Current Behavior
If you flag a post, after the flag styling is applied, selecting text doesn't bring up the quote button.
The same behavior happens when unflagging. The quote button appears on page load, but after the flag is dismissed and the default styling is restored, the quote button doesn't appear again.
After a page reload or moving the post out of the loaded page range and back in, it works again.
Steps to Reproduce
Expected Behavior
Quote feature should continue working.
Screenshots
Environment
Output of
php flarum info
Possible Solution
I think the problem is with the
$('.Post-body')
selector/DOM. The Mentions extension captures a reference to.Post-body
inoncreate
:https://github.com/flarum/framework/blob/ab56aefeaaefc93566179ba9a0213183fc8e777b/extensions/mentions/js/src/forum/addPostQuoteButton.js#L9-L14
But Flags inserts a new DOM node above
.Post-body
:https://github.com/flarum/framework/blob/ab56aefeaaefc93566179ba9a0213183fc8e777b/extensions/flags/js/src/forum/addFlagsToPosts.js#L86-L95
I suspect Mithril re-uses the DOM nodes instead of shifting them, which causes the jQuery object in Mentions to now point to the post header instead.
We should maybe introduce keyed vdom nodes to prevent the DIVs from being re-purposed by Mithril in that area. But this might break backward compatibility if any extension inserts a node without a key.
Additional Context
Observed first on Discuss while approving posts flagged by Approval extension. But it's not actually related to Approval.