Ionaru / Ionaru/easy-markdown-editor
On a pristine form - the reset event will not include the EasyMDE text area value.
- Dominant language
- JavaScript
- Stars
- 3.1k
- Forks
- 363
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
If we include our target textarea in a form, and the add the `name` attribute, then we can treat the EasyMDE textarea like any form element and expect it to otherwise expect it to have the same behaviour as regular form elements.
When reseting a form, the event dispatched should include the current value of the text area. However, if it it is untouched there will be no value associated.
**nb.** The bug occurs for text areas declared like this:
```
Reset
Submit
const easymde = new EasyMDE({
element: document.getElementById('my-text-area'),
initialValue: 'I am initial value',
});
```
Text areas that are declared like this work fine:
```
I am initial value
Reset
Submit
const easymde = new EasyMDE({
element: document.getElementById('my-text-area')
});
```
**To Reproduce**
Reproduction here:
https://stackblitz.com/edit/easymde-tc8blv/?file=index.html
To see expected behaviour:
Click the second 'reset' button - this is a plain non-easymde text area in a form.
Note that the value of the text area is shown in the alert.
Now click the first reset button - there is no value for the text area.
**Expected behavior**
The initial value should treated as part of the reset event.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Version information**
- OS: [e.g. Windows, MacOS]
- Browser: [e.g. Chrome 72]
- EasyMDE version: [e.g. 2.5.1]
**Additional context**
Note:
This problem only exists if passing in `initialValue` as part of the options to the `new EasyMDE(..)` call. If you put the initialValue in to the textarea it self like:
`I am the initial content` then it works fine.
Updated: See: https://stackblitz.com/edit/easymde-7jdndz/?file=index.html
Contributor guide
Assessment
This issue has not been assessed yet.