Skip to content
Snippets Groups Projects
Verified Commit 07830391 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3397594 by Utkarsh_33, lauriii: Race condition on AJAX change event and form submission

(cherry picked from commit 27f9fa66)
parent 01b19986
No related branches found
No related tags found
20 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core,!5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases...,!5716Draft: Issue #3401102 by Spokje, longwave, smustgrave: Nightwatch artifacts on GitLab not retained,!5674Transaction autocommit during shutdown relies on unreliable object destruction order,!5644Issue #3395563 by nireneko, marvil07, lauriii, borisson_, smustgrave, Wim...
Pipeline #46557 passed
Pipeline: drupal

#46558

    ......@@ -102,6 +102,32 @@
    },
    };
    // Override the beforeSend method to disable the submit button until
    // the AJAX request is completed. This is done to avoid the race
    // condition that is being caused by change event listener that is
    // attached to every form element inside field storage config edit
    // form to update the field config form based on changes made to the
    // storage settings.
    const originalAjaxBeforeSend = Drupal.Ajax.prototype.beforeSend;
    // eslint-disable-next-line func-names
    Drupal.Ajax.prototype.beforeSend = function () {
    // Disable the submit button on AJAX request initiation.
    $('.field-config-edit-form [data-drupal-selector="edit-submit"]').prop(
    'disabled',
    true,
    );
    // eslint-disable-next-line prefer-rest-params
    return originalAjaxBeforeSend.apply(this, arguments);
    };
    // Re-enable the submit button after AJAX request is completed.
    // eslint-disable-next-line
    $(document).on('ajaxComplete', () => {
    $('.field-config-edit-form [data-drupal-selector="edit-submit"]').prop(
    'disabled',
    false,
    );
    });
    /**
    * Namespace for the field UI overview.
    *
    ......
    ......@@ -259,6 +259,7 @@ public function form(array $form, FormStateInterface $form_state) {
    }
    $form['#prefix'] = '<div id="field-combined">';
    $form['#suffix'] = '</div>';
    $form['#attached']['library'][] = 'field_ui/drupal.field_ui';
    return $form;
    }
    ......
    ......@@ -2,6 +2,7 @@
    namespace Drupal\Tests\field_ui\FunctionalJavascript;
    use Drupal\field\Entity\FieldConfig;
    use Drupal\field\Entity\FieldStorageConfig;
    use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
    use Drupal\Tests\field_ui\Traits\FieldUiJSTestTrait;
    ......@@ -325,4 +326,26 @@ public function testFieldTypeOrder() {
    }
    }
    /**
    * Tests the form validation for allowed values field.
    */
    public function testAllowedValuesFormValidation() {
    FieldStorageConfig::create([
    'field_name' => 'field_text',
    'entity_type' => 'node',
    'type' => 'text',
    ])->save();
    FieldConfig::create([
    'field_name' => 'field_text',
    'entity_type' => 'node',
    'bundle' => 'article',
    ])->save();
    $this->drupalGet('/admin/structure/types/manage/article/fields/node.article.field_text');
    $page = $this->getSession()->getPage();
    $page->findField('edit-field-storage-subform-cardinality-number')->setValue('-11');
    $page->findButton('Save settings')->click();
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->pageTextContains('Limit must be higher than or equal to 1.');
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment