forem / forem

For empowering community 🌱
https://forem.com
GNU Affero General Public License v3.0
21.94k stars 4.03k forks source link

"Revert new changes" in the editor does not remove the body #13324

Closed rhymes closed 3 years ago

rhymes commented 3 years ago

Describe the bug

In the editor: after having added a title, tags and the content if you click on "Revert new changes" and confirmed the popup, the editor will remove the title, the tags but not the content.

To Reproduce

  1. go to https://dev.to/new
  2. fill in the title, tags and add content in the body of the article
  3. click "Revert new changes" at the bottom and confirm
  4. the content is still there

Expected behavior

The content should be removed as well

Desktop (please complete the following information):

github-actions[bot] commented 3 years ago

Thanks for the issue, we will take it into consideration! Our team of engineers is busy working on many types of features, please give us time to get back to you.

Feature requests that require more discussion may be closed. Read more about our feature request process on forem.dev.

To our amazing contributors: issues labeled type: bug are always up for grabs, but for feature requests, please wait until we add a ready for dev before starting to work on it.

To claim an issue to work on, please leave a comment. If you've claimed the issue and need help, please ping @forem/oss. The OSS Community Manager or the engineers on OSS rotation will follow up.

For full info on how to contribute, please check out our contributors guide.

nickytonline commented 3 years ago

This is related to the new mention autocomplete feature.

The mention autocomplete has two inputs that it toggles between, so most likely both are not being cleared.

An end to end test should be added for this to avoid future regressions of this functionality.

nickytonline commented 3 years ago

I did a bit of digging and the article body is getting reset, but the state in the MentionAutocomplete component is not updating it's text, because the reset data is not being updated via the setText function from a useState hook. The input is not a controlled input component. Only the initial value of the article body is set from the parent. From there, the MentionAutoComplete is an uncontrolled form input component.

https://github.com/forem/forem/blob/24a865e81f6c5a77fc69d8fb9ba8eec6f7bee40b/app/javascript/crayons/MentionAutocompleteTextArea/MentionAutocompleteTextArea.jsx#L103-L105

aitchiss commented 3 years ago

Closing this as I believe it was fixed in #13365