Unverified Commit b57729b9 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2817081 by nod_, Baysaa, rensingh99, AndyF, amoebanath, alexpott,...

Issue #2817081 by nod_, Baysaa, rensingh99, AndyF, amoebanath, alexpott, lauriii, andrewmacpherson: Show 'Edit summary' links on multi-value long text field with summary
parent 4313e7f4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Tests\text\FunctionalJavascript;

use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;

/**
@@ -72,6 +73,13 @@ public function testTextSummaryBehavior() {

    $this->assertSummaryToggle();

    // Repeat test with unlimited cardinality field.
    $body_field_storage = FieldStorageConfig::loadByName('node', 'body');
    $body_field_storage->setCardinality(-1);
    $body_field_storage->save();

    $this->assertSummaryToggle();

    // Test summary is shown when non-empty.
    $node = $this->createNode([
      'body' => [
+11 −0
Original line number Diff line number Diff line
@@ -28,6 +28,17 @@
          $fullLabel = $('<label></label>').prependTo($full);
        }

        // To ensure the summary toggle is shown in case the label is hidden
        // (in multivalue fields in particular), show the label but hide
        // the original text of the label.
        if ($fullLabel.hasClass('visually-hidden')) {
          $fullLabel.html(
            (index, oldHtml) =>
              `<span class="visually-hidden">${oldHtml}</span>`,
          );
          $fullLabel.removeClass('visually-hidden');
        }

        // Set up the edit/hide summary link.
        const $link = $(
          `<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">${Drupal.t(
+7 −0
Original line number Diff line number Diff line
@@ -19,6 +19,13 @@
          $fullLabel = $('<label></label>').prependTo($full);
        }

        if ($fullLabel.hasClass('visually-hidden')) {
          $fullLabel.html(function (index, oldHtml) {
            return "<span class=\"visually-hidden\">".concat(oldHtml, "</span>");
          });
          $fullLabel.removeClass('visually-hidden');
        }

        var $link = $("<span class=\"field-edit-link\"> (<button type=\"button\" class=\"link link-edit-summary\">".concat(Drupal.t('Hide summary'), "</button>)</span>"));
        var $button = $link.find('button');
        var toggleClick = true;