Commit 9c11dbc8 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

fix: #3567770 Media Library message persists after deselecting items to fix overflow

By: julio_retkwa
By: smustgrave
(cherry picked from commit e374c30d)
(cherry picked from commit c27ae7eb)
parent 03b4f37c
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -311,6 +311,14 @@

      function checkEnabled() {
        updateSelectionCount(settings.media_library.selection_remaining);
        // Clear any error messages when the selection is within the allowed
        // limit. A negative remaining value means unlimited selection.
        if (
          settings.media_library.selection_remaining < 0 ||
          currentSelection.length <= settings.media_library.selection_remaining
        ) {
          $('#media-library-messages').empty();
        }
        if (
          currentSelection.length === settings.media_library.selection_remaining
        ) {
+3 −1
Original line number Diff line number Diff line
@@ -126,10 +126,12 @@ public function testWidgetOverflow(?string $selected_operation): void {
    $this->pressInsertSelected(NULL, FALSE);
    $this->waitForElementTextContains('.messages--error', 'There are currently 5 items selected. The maximum number of items for the field is 2. Remove 3 items from the selection.');
    $assert_session->elementNotExists('css', '.messages--warning');
    // Once the extra items are deselected, all should be well.
    // Once the extra items are deselected, the error message should be
    // automatically cleared.
    $this->deselectMediaItem(2);
    $this->deselectMediaItem(3);
    $this->deselectMediaItem(4);
    $assert_session->elementNotExists('css', '.messages--error');
    $this->pressInsertSelected('Added 2 media items.');
  }