Problem/Motivation
While testing, I've noted two different, related issues:
- the initial form submits on any mousedown event
- the form can be submitted if neither button was chosen or if the textfield is empty, but the submission doesn't get recorded when neither button was chosen
Steps to reproduce
For both, install the module, and place the block in a region on one or more nodes.
This is probably not reproducible everywhere (see below).
- right-click on the "Send feedback" button without releasing the mouse-button
The form submits.
- type a message into the textarea (optional)
- click the "Send feedback" button
The form submits; even when a message is provided, it's not recorded in the feedback view.
Proposed resolution
There are two different things at play here:
- this being Drupal, we aren't guaranteed a consistent form id: in my instance, it's
edit-feedback-send--2
- the "Send feedback" button is not disabled until after one of the feedback buttons is clicked
For (1) the solution is to replace all instances of #edit-feedback-send
with something that will not change like .feedback-btn__send-comment
or [data-drupal-selector='edit-feedback-send']
.
For (2) the solution is one of:
- move the line that disables the submit button,
$("#edit-feedback-send").prop("disabled", true);
, to just before the click handler, or even better, remove the line from javascript altogether and
- add
'disabled' => TRUE,
to the form attributes array in AdminFeedbackAjaxForm.php
Together, these changes mostly fix the original two issues--I'm still trying to understand why mousedown events on the "Send feedback" button are able to submit the form.
Remaining tasks
Find out why mousedown is enough to submit the form, address that, and create an MR :)
User interface changes
N/a
API changes
N/a
Data model changes
N/a