diff --git a/js/soft-limit.js b/js/soft-limit.js
index 9c4e27e..116ac59 100644
--- a/js/soft-limit.js
+++ b/js/soft-limit.js
@@ -44,16 +44,18 @@
var id = facet.data('drupal-facet-id');
var showLessLabel = settings.facets.softLimitSettings[id].showLessLabel;
var showMoreLabel = settings.facets.softLimitSettings[id].showMoreLabel;
- $('').text(showMoreLabel).on('click', function () {
- if (facet.find('li:hidden').length > 0) {
- facet.find('li:gt(' + zero_based_limit + ')').slideDown();
- $(this).addClass('open').text(showLessLabel);
- }
- else {
- facet.find('li:gt(' + zero_based_limit + ')').slideUp();
- $(this).removeClass('open').text(showMoreLabel);
- }
- return false;
+ $('')
+ .text(showMoreLabel)
+ .on('click', function () {
+ if (facet.find('li:hidden').length > 0) {
+ facet.find('li:gt(' + zero_based_limit + ')').slideDown();
+ $(this).addClass('open').text(showLessLabel);
+ }
+ else {
+ facet.find('li:gt(' + zero_based_limit + ')').slideUp();
+ $(this).removeClass('open').text(showMoreLabel);
+ }
+ return false;
}).insertAfter($(this));
});
};
diff --git a/tests/src/FunctionalJavascript/WidgetJSTest.php b/tests/src/FunctionalJavascript/WidgetJSTest.php
index 1059247..587e98b 100644
--- a/tests/src/FunctionalJavascript/WidgetJSTest.php
+++ b/tests/src/FunctionalJavascript/WidgetJSTest.php
@@ -3,6 +3,7 @@
namespace Drupal\Tests\facets\FunctionalJavascript;
use Drupal\block\Entity\Block;
+use Drupal\facets\Entity\Facet;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
use Drupal\search_api\Entity\Index;
@@ -77,6 +78,7 @@ public function testLinksShowMoreLess() {
'facet_source_id' => 'search_api:views_page__search_api_test_view__page_1',
'field_identifier' => 'type',
'empty_behavior' => ['behavior' => 'none'],
+ 'weight' => 1,
'widget' => [
'type' => 'links',
'config' => [
@@ -109,11 +111,21 @@ public function testLinksShowMoreLess() {
// Make sure the show more / show less links are shown.
$this->assertSession()->linkExists('Show more');
- $edit = [
- 'widget_config[soft_limit_settings][show_more_label]' => 'Moar Llamas',
- ];
- $this->drupalPostForm('admin/config/search/facets/' . $id . '/edit', $edit, 'Save');
+ // Change the link label of show more into "Moar Llamas".
+ $facet = Facet::load('owl');
+ $facet->setWidget('links', [
+ 'show_numbers' => TRUE,
+ 'soft_limit' => 1,
+ 'soft_limit_settings' => [
+ 'show_less_label' => 'Show less',
+ 'show_more_label' => 'Moar Llamas',
+ ],
+ ]);
+ $facet->save();
+
+ // Check that the new configuration is used now.
$this->drupalGet('search-api-test-fulltext');
+ $this->assertSession()->linkNotExists('Show more');
$this->assertSession()->linkExists('Moar Llamas');
}