Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommentPost content script tags not executed during oncreate #2412

Closed
clarkwinkelmann opened this issue Oct 25, 2020 · 1 comment · Fixed by #2415
Closed

CommentPost content script tags not executed during oncreate #2412

clarkwinkelmann opened this issue Oct 25, 2020 · 1 comment · Fixed by #2415
Assignees

Comments

@clarkwinkelmann
Copy link
Member

Bug Report

Current Behavior
When a post is loaded and its template contains javascript, the javascript doesn't run until the post experiences an onupdate cycle.

This can be experienced with syntax-highlighted code blocks, but probably also other extensions.

Steps to Reproduce

  1. Create post with code block
  2. Refresh page
  3. See post is not highlighted

This can probably be reproduced with other community extensions. I think the code block is the only one from core with javascript in the template itself.

Expected Behavior
Javascript should run during the first render

Screenshots
image

Environment

  • Flarum version: beta 14
  • Website URL: tested locally

Possible Solution
We need to call the code from onupdate in oncreate. Previously that code ran in config without any regard to isInitialized.

Beta 13 code

https://github.com/flarum/core/blob/fd371c1203439810af8f6814cdff402faebf4126/js/src/forum/components/CommentPost.js#L57-L72

Current code

https://github.com/flarum/core/blob/c9a04fe009abf474b39f562e9d4bf13c5ecf25c8/js/src/forum/components/CommentPost.js#L59-L74

While we're at it, I think we should also call super.onupdate with a vnode parameter. If an extension was to extend Post.prototype.onupdate, they wouldn't be able to access vnode because CommentPost forgets to pass it up.

Additional Context
Reported by RebelCoderRU here https://discuss.flarum.org/d/25227-code-highlighting-not-working-properly-on-beta-14

@askvortsov1 askvortsov1 added this to the 0.1.0-beta.14.1 milestone Oct 25, 2020
@askvortsov1
Copy link
Sponsor Member

Unfortunately this doesn't fix the issue. From local testing, code blocks are highlighted during editing and not on a regular page because its shown in the ComposerPostPreview component. This chunk of code does nothing in beta 14 (which is probably the issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants