Currently, when the Email Contact Link formatter is configured with modal: true, the ContactController doesn't properly distinguish between Ajax and non-Ajax requests. This can lead to unexpected
behavior when users access the contact form directly via URL or when JavaScript is disabled.
The controller attempts to display a modal dialog regardless of request type, which doesn't work properly for non-Ajax requests and can result in poor user experience or functionality issues.
modal: trueImplement \Drupal\Core\Ajax\AjaxHelperTrait::isAjax() in ContactController to properly check request type and handle modal display logic:
modal setting is true AND request is Ajax → display form in modalmodal setting is true AND request is NOT Ajax → display form as regular pagemodal setting is false → display form as regular pageImplementation steps:
use Drupal\Core\Ajax\AjaxHelperTrait; to ContactControlleruse AjaxHelperTrait;ContactController::content() to use $this->isAjax() checkif (!empty($field_settings['modal']) && $this->isAjax())ContactController to use AjaxHelperTraitcontent() methodtestModalRedirectWhenNotAjax()When the modal setting is enabled but the request is not Ajax (e.g., direct URL access or JavaScript disabled), the contact form will display as a regular page instead of attempting to show in a modal dialog. This provides better
accessibility and graceful degradation.
None. This change is internal to the ContactController and doesn't affect any public APIs.
None.
Needs review
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.