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

Issue fork drupal-3061838

Command icon 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:

Comments

mglaman created an issue. See original summary.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tinto’s picture

Version: 9.5.x-dev » 9.4.x-dev
Issue tags: +Bug Smash Initiative, +Needs steps to reproduce

I checked /core/lib/Drupal/Core/Render/Element/RenderElement.php in 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.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Issue summary: View changes
Issue tags: -Needs steps to reproduce +Novice

This came up as the daily BSI target and definitely still appears to be relevant

megachriz’s picture

Issue summary: View changes

The 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.

kart.vajakas made their first commit to this issue’s fork.

kart.vajakas’s picture

Issue tags: +Vienna2025

I 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.

katzilla’s picture

working on this now...

katzilla’s picture

Issue summary: View changes
StatusFileSize
new810.73 KB
new1.41 MB

Applied 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!

katzilla’s picture

working on a test...

vijaycs85’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Per #18

katzilla’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Nice! Seems to have some pipeline errors so the tests didn’t run

pguillard made their first commit to this issue’s fork.

pguillard’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Thanks but why inheritdocs on emailfieldCallback? That's not a function with docs anywhere.

Pipeline still has errors.

parth_sinha made their first commit to this issue’s fork.

xjm’s picture

Issue tags: +Nara2025

Unit tests are failing due to errors like:

    PHP Fatal error:  Class Drupal\node\Entity\Node inherits both Drupal\Core\Entity\EntityPublishedInterface::NOT_PUBLISHED and Drupal\node\NodeInterface::NOT_PUBLISHED, which is ambiguous in /builds/issue/drupal-3523070/core/modules/node/src/Entity/Node.php on line 98
---- Drupal\Tests\content_moderation\Unit\StateTransitionValidationTest ----

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!

kazuko.murata’s picture

I'm attending DrupalConNara and will try this issue.

otofu made their first commit to this issue’s fork.

otofu’s picture

I fixed an error in the CI spell check.

kazuko.murata’s picture

Status: Needs work » Needs review

Several 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?

a_ramos’s picture

I'm currently reviewing this issue here in DrupalCon Nara. Thank you @rduterte for mentoring!

a_ramos’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.27 MB

Spell 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!

silverham’s picture

(added comment to enure contribution is tracked for helping with with development environment setup and mentoring the real MVPs)

  • catch committed aeec851c on 11.3.x
    fix: #3061838 Email element does not have default #ajax event
    
    By:...

  • catch committed 27e9d0c2 on 11.x
    fix: #3061838 Email element does not have default #ajax event
    
    By:...
catch’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/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.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.