Problem/Motivation
When RenderElement::preRenderAjaxForm processes #ajax, it assigns default triggering events based on element types.
Currently, all text inputs check for the blur event:
case 'password':
case 'textfield':
case 'number':
case 'tel':
case 'textarea':
$element['#ajax']['event'] = 'blur';
break;
The email input is missing. When adding #ajax to an email element, nothing happens.
I'm assuming this falls under the render system since it is part of the processing system rather than actual AJAX.
Steps to reproduce
- add $settings['extension_discovery_scan_tests'] = TRUE; to my settings.php
- activate the module "AJAX form test mock module"
- access the form under /ajax_forms_test_get_form
- add an email field with an ajax-callback in the form (AjaxFormsTestSimpleForm.php)
- put your cursor into the email-field and tab out of it -> no ajax call happens, the focus gets lost
Proposed resolution
Add email to the switch case above.
Remaining tasks
- Add 'email' to the switch case above.
- Provide the list of steps to reproduce the issue.
- Add test coverage that it's there?
User interface changes
NA
Introduced terminology
NA
API changes
NA
Data model changes
NA
Release notes snippet
NA
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | 3061838-33-reviewed.mov | 4.27 MB | a_ramos |
| #17 | 3061838-17-after.mov | 1.41 MB | katzilla |
| #17 | 3061838-17-before.mov | 810.73 KB | katzilla |
Issue fork drupal-3061838
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 11.x
compare
- 3061838-email-element-does
changes, plain diff MR !13519
Comments
Comment #8
tintoI checked
/core/lib/Drupal/Core/Render/Element/RenderElement.phpin Drupal 9.5.x-dev and the lines mentioned in this issue seem to have remained unchanged - still no reference to any email type field.Therefore I'm assuming that this issue still persists, but it would be great to have some clear steps to reproduce this issue as a first step towards a patch.
Comment #11
smustgrave commentedThis came up as the daily BSI target and definitely still appears to be relevant
Comment #12
megachrizThe next step is to find out how to reproduce the issue. Probably by defining an email field in a custom module with a #ajax attribute. Requires some familiarity with the Ajax subsystem.
Comment #14
kart.vajakas commentedI worked on this issue as part of DrupalCon Vienna 2025 First contribution workshop.
I was able to reproduce the issue and adding the missing case "email" and tabbing away from the field resulted in Ajax being triggered in the Network tab. Email inputs should now trigger Ajax on blur like other text inputs.
Comment #16
katzillaworking on this now...
Comment #17
katzillaApplied the patch and tested with the described procedure from steps to reproduce above. Patch works, made a recording of before/after the patch with a test-form (see steps to reproduce).
mentored by @vijaycs85 at Drupalcon Vienna 2025 - thanks!
Comment #18
katzillaworking on a test...
Comment #19
vijaycs85Comment #20
smustgrave commentedPer #18
Comment #21
katzillaComment #22
smustgrave commentedNice! Seems to have some pipeline errors so the tests didn’t run
Comment #24
pguillard commentedComment #25
smustgrave commentedThanks but why inheritdocs on emailfieldCallback? That's not a function with docs anywhere.
Pipeline still has errors.
Comment #27
xjmUnit tests are failing due to errors like:
This would be a good sort of thing for a novice contributor to resolve during our contribution day!
The Drupal Contribution Mentoring team is triaging issues for DrupalCon Nara 2025, and we are reserving this issue for Mentored Contribution during the event.
After November 19, this issue returns to being open to all. Thanks!
Comment #28
kazuko.murata commentedI'm attending DrupalConNara and will try this issue.
Comment #30
otofu commentedI fixed an error in the CI spell check.
Comment #31
kazuko.murata commentedSeveral people collaborated on this issue during DrupalCon Nara 2025.
@otofu @kazuko.murata @gengo_k
Many others also supported us in tackling this issue.
@xjm @johnalbin @dokumori
Thank you so much!!
Could you please review this merge request?
Comment #32
a_ramos commentedI'm currently reviewing this issue here in DrupalCon Nara. Thank you @rduterte for mentoring!
Comment #33
a_ramos commentedSpell check error in pipeline is now passed and no errors found.
Also the email field is working as expected.
Thank you @rduterte and @silverham for mentoring!
Comment #34
silverham commented(added comment to enure contribution is tracked for helping with with development environment setup and mentoring the real MVPs)
Comment #37
catchCommitted/pushed to 11.x and cherry-picked to 11.3.x, thanks!
I think I got everyone who was mentioned in the comments here for mentoring at the sprint etc., but apologies if I missed anyone.