post_status_form: fix enter key in subject field

This fixes random actions being triggered by the enter key while the
subject field is focused.

When pressing enter, the browser simulates a click on the first "submit"
button it finds in the form.
A submit button is a button without `type="button"` set.
Remediate this by setting the type attribute on all but the "Post"
button.

Additionally, inhibit the enter key in the subject field (ctrl+enter
still works).
This commit is contained in:
novenary 2024-09-17 00:36:48 +03:00
parent f391cf70a4
commit 5886765d89
2 changed files with 7 additions and 0 deletions

View file

@ -24,6 +24,7 @@
<button <button
v-if="options.length > 2" v-if="options.length > 2"
class="delete-option button-unstyled -hover-highlight" class="delete-option button-unstyled -hover-highlight"
type="button"
@click="deleteOption(index)" @click="deleteOption(index)"
> >
<FAIcon icon="times" /> <FAIcon icon="times" />
@ -32,6 +33,7 @@
<button <button
v-if="options.length < maxOptions" v-if="options.length < maxOptions"
class="add-option faint button-unstyled -hover-highlight" class="add-option faint button-unstyled -hover-highlight"
type="button"
@click="addOption" @click="addOption"
> >
<FAIcon <FAIcon

View file

@ -18,6 +18,7 @@
> >
<button <button
class="button-unstyled -link" class="button-unstyled -link"
type="button"
@click="openProfileTab" @click="openProfileTab"
> >
{{ $t('post_status.account_not_locked_warning_link') }} {{ $t('post_status.account_not_locked_warning_link') }}
@ -136,6 +137,7 @@
class="form-post-subject" class="form-post-subject"
@input="onSubjectInput" @input="onSubjectInput"
@focus="focusSubjectInput()" @focus="focusSubjectInput()"
@keydown.exact.enter.prevent
> >
</EmojiInput> </EmojiInput>
<i18n-t <i18n-t
@ -272,6 +274,7 @@
<button <button
class="emoji-icon button-unstyled" class="emoji-icon button-unstyled"
:title="$t('emoji.add_emoji')" :title="$t('emoji.add_emoji')"
type="button"
@click="showEmojiPicker" @click="showEmojiPicker"
> >
<FAIcon icon="smile-beam" /> <FAIcon icon="smile-beam" />
@ -281,6 +284,7 @@
class="poll-icon button-unstyled" class="poll-icon button-unstyled"
:class="{ selected: pollFormVisible }" :class="{ selected: pollFormVisible }"
:title="$t('polls.add_poll')" :title="$t('polls.add_poll')"
type="button"
@click="togglePollForm" @click="togglePollForm"
> >
<FAIcon icon="poll-h" /> <FAIcon icon="poll-h" />
@ -290,6 +294,7 @@
class="spoiler-icon button-unstyled" class="spoiler-icon button-unstyled"
:class="{ selected: subjectVisible }" :class="{ selected: subjectVisible }"
:title="$t('post_status.toggle_content_warning')" :title="$t('post_status.toggle_content_warning')"
type="button"
@click="toggleSubjectVisible" @click="toggleSubjectVisible"
> >
<FAIcon icon="eye-slash" /> <FAIcon icon="eye-slash" />