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

JavaScript code is rendered while saving a new discussion title #2619

Closed
matteocontrini opened this issue Feb 20, 2021 · 5 comments · Fixed by #2693
Closed

JavaScript code is rendered while saving a new discussion title #2619

matteocontrini opened this issue Feb 20, 2021 · 5 comments · Fixed by #2693
Milestone

Comments

@matteocontrini
Copy link
Contributor

matteocontrini commented Feb 20, 2021

Bug Report

Current Behavior

When editing the title of a discussion, while the saving is in progress, the title of the discussion beneath the modal becomes some JavaScript code.

2021-02-20_23-19-10.mp4

Steps to Reproduce

  1. Go to https://nightly.flarum.site/
  2. Create a discussion
  3. Rename the discussion title
  4. Notice that while the new title is being saved, the title beneath the modal becomes some JavaScript code

Environment

  • Flarum nightly
@Ralkage
Copy link
Contributor

Ralkage commented Feb 25, 2021

I can confirm this is also reproducible on https://beta.flarum.site which is on Beta 15 atm:

2021-02-25_17-22-33.mp4

@deebug
Copy link

deebug commented Mar 12, 2021

I have a recording with a slight delay on when the issue occurs. Might be helpfull.

rename.mp4

@dsevillamartin
Copy link
Member

I think this is because we're passing the Stream function instead of its value.

https://github.com/flarum/core/blob/0a6c5217c11e625aab5deec05bf6a6caf31bfa0d/js/src/forum/components/RenameDiscussionModal.js#L14

https://github.com/flarum/core/blob/0a6c5217c11e625aab5deec05bf6a6caf31bfa0d/js/src/forum/components/RenameDiscussionModal.js#L52-L60

Looks like the Mithril request automatically calls the function, but the Model value is temporarily set to the function and not its output.

The fix here, if I'm correct, would be to change const title = this.newTitle; to const title = this.newTitle();

@askvortsov1
Copy link
Member

That fixes it for me locally. Could you open a PR?

@dsevillamartin
Copy link
Member

@askvortsov1 Done :)

@askvortsov1 askvortsov1 added this to the 0.1 milestone Mar 16, 2021
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.

5 participants