OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Pressing "Enter" button while typing in a markdown input, the form submit is triggered

Open MikeAlhayek opened this issue 3 years ago • 9 comments

Describe the bug

In a markdown field, if a user hits "Enter" button on their keyboard, the form get submitted instead of adding a new line.

To Reproduce

Steps to reproduce the behavior:

  1. Created a content type
  2. add a Markdown field with standard editor
  3. Create a new content item of that content type
  4. focus the field input and click "enter"

Expected behavior

When "Enter" in clicked, I expect a new line to be inserted instead of form submitting.

MikeAlhayek avatar Sep 02 '22 21:09 MikeAlhayek

Is the same thing happen in Html field?

hishamco avatar Sep 03 '22 16:09 hishamco

I don't think so. At least I don't think I recall experiencing this issue outside a standard Markdown field.

MikeAlhayek avatar Sep 03 '22 17:09 MikeAlhayek

This is something that generally we would think that it be part of the Markdown editor itself. Looks like it is a regression from previous versions else it would have been reported way before.

Skrypt avatar Sep 05 '22 22:09 Skrypt

@Skrypt I have not had time to look into it. But it works fine when you use textarea. The issue is when using a standard input. Maybe it does not like the input type? Not sure. I'll try to look into it when I have time.

At the same time, why do we even use a text input for a markdown by default? How can that ever be useful? Maybe the standard markdown should be textarea? Is there a good reason why markdown would be used in a in standard text input?

MikeAlhayek avatar Sep 10 '22 04:09 MikeAlhayek

AFAIK textarea support enter key while others triggers the default submit button on the page. So, using textarea should fix the issue

hishamco avatar Sep 10 '22 10:09 hishamco

@hishamco changing it would fix the issue. But at the same time we have Textarea editor for Markdown. I don't know if there is a valid reason why the standard editor uses an text input.

MikeAlhayek avatar Sep 10 '22 17:09 MikeAlhayek

Really I don't know!! I'm expecting using TextArea for such editors

hishamco avatar Sep 10 '22 17:09 hishamco

Apparently it a standard html behavior that for some reason I never paid attention to it. Anytime you hit enter while typing in html input of a type text will submit the form. So I don't think this is an issue.

I don't know if text make sense for markdown, so I suggest we change it to textarea.

MikeAlhayek avatar Sep 10 '22 18:09 MikeAlhayek

Anytime you hit enter while typing in html input of a type text will submit the form. So I don't think this is an issue.

That's what I refered too here

hishamco avatar Sep 11 '22 04:09 hishamco

Would you use Multi-line or WYSIWYG as the default editor?

Piedone avatar May 20 '24 00:05 Piedone

Yes using Multi-line or WYSIWYG works just fine. I think the problem here was that the Markdown part use textarea by default. I think it may not be a bad idea to use Multi-line "textarea" by default drop the support for a single-line. Single-line is not useful when writing markdown.

MikeAlhayek avatar May 28 '24 17:05 MikeAlhayek

Let's do multi-line for the lack of dependencies, then.

Piedone avatar May 28 '24 21:05 Piedone