Verified Commit 703e5974 authored by godotislate's avatar godotislate
Browse files

fix: #3608733 Ajax error when creating a new content view

By: jonasanne
By: juliengui
By: smustgrave
By: lendude
(cherry picked from commit 77849a93)
parent 9e46fcbf
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ trait ViewsFormAjaxHelperTrait {
  protected function addAjaxTrigger(array &$wrappingElement, string $triggerKey, array $refreshParents): void {
    // Add the AJAX behavior to the triggering element.
    $triggeringElement = &$wrappingElement[$triggerKey];
    $triggeringElement['#ajax']['callback'] = static::class . ':ajaxUpdateForm';
    $triggeringElement['#ajax']['callback'] = static::class . '::ajaxUpdateForm';

    // We do not use \Drupal\Component\Utility\Html::getUniqueId() to get an ID
    // for the AJAX wrapper. It remembers IDs across AJAX requests (and won't
@@ -222,7 +222,7 @@ public static function addAjaxWrapper(array $element, FormStateInterface $formSt
   * @return array
   *   Render array.
   */
  public function ajaxUpdateForm(array $form, FormStateInterface $formState): array {
  public static function ajaxUpdateForm(array $form, FormStateInterface $formState): array {
    // The region that needs to be updated was stored in a property of the
    // triggering element by self::addAjaxTrigger(), so all we have to do is
    // retrieve that here.
+4 −0
Original line number Diff line number Diff line
@@ -95,6 +95,10 @@ public function testCreateViewWizard(): void {
    $this->assertNotNull($page->findField('show[type]'), 'The "of type" filter is added for nodes when there is at least one node type.');
    $this->assertEquals('fields', $page->findField('page[style][row_plugin]')->getValue(), 'The page display format was not changed from a valid value.');
    $this->assertEquals('fields', $page->findField('block[style][row_plugin]')->getValue(), 'The block display format was not changed from a valid value.');

    $page->selectFieldOption('show[type]', 'page');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSame('page', $page->findField('show[type]')->getValue());
  }

}