Problem/Motivation
$form['no'] has no #ajax. The reason panel is opened purely by the module's JS behaviour, which selects the button by its English label:
$(once('did-this-help', '.did-this-help .form-submit[value="No"]', context)).each(...)
#value is $this->t('No'), so on a site whose interface language is not English the rendered button is e.g. value="Nei" (Icelandic) and that selector matches nothing. No handler attaches, and the click falls through to a native form submit: a full page POST that re-renders the block in its initial state. Nothing is recorded either, because submitForm() is empty and only the AJAX callback writes to the table.
Measured on two sites running the same 2.0.8:
interface language | rendered button | data-once on the button
-------------------|-----------------|------------------------
English | value="No" | did-this-help
Icelandic | value="Nei" | (none)
The no-choice-wrapper markup, its radios and the Send button are all present in the DOM in both cases -- only the opener is missing. So the panel stays permanently hidden and the whole "No" half of the feature is unreachable.
This looks like the undiagnosed cause of #3545452, which reported exactly this symptom ("Clicking 'No' reloads the page instead of submitting feedback via AJAX") and was closed as "works as designed" with no explanation given. I do not think it is by design: the reason panel that click is supposed to open is built and shipped by the module itself, and is otherwise dead markup.
Steps to reproduce
- Install Did this help?, place the block.
- Add a second language and set the interface language to it (e.g. Icelandic).
- Visit a page with the block and press the "No" button.
- The page reloads and the reason panel never opens. The same click in English opens the panel.
Proposed resolution
Stop selecting on a translated label. Add a stable class in buildForm() and match on that instead:
$form['no']['#attributes']['class'][] = 'did-this-help-no';
$(once('did-this-help', '.did-this-help .did-this-help-no', context))
A class rather than #edit-no, so it keeps working if the block is rendered twice on one page and the id becomes edit-no--2.
Patch against 2.0.8 attached.
Remaining tasks
Review. Note that fixing this makes the Send path reachable, where #3622258 fixes a TypeError that the "Other" reason triggers.
User interface changes
The "No" button opens the reason panel on non-English sites, as it already does in English. No visual change in English.
API changes
None. The button gains a did-this-help-no class; the CSS does not key off it.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| did_this_help-no-button-localized-selector.patch | 1.16 KB | drupalviking |
Comments
Comment #3
levmyshkinThanks for the report and the patch, @drupalviking. I applied and committed the fix (the JS now targets a stable did-this-help-no class instead of the translated button label) to the 2.0.x branch and released it in 2.0.9.
Marking as fixed.
Comment #5
levmyshkin