diff --git a/js/soft-limit.js b/js/soft-limit.js
index ebbc9ec..d70f9a1 100644
--- a/js/soft-limit.js
+++ b/js/soft-limit.js
@@ -35,14 +35,14 @@
facetsList.children('li:gt(' + zero_based_limit + ')').once().hide();
// Add "Show more" / "Show less" links.
- facetsList.once().filter(function () {
+ facetsList.once('js-facet-showmoreless').filter(function () {
return $(this).find('li').length > limit;
}).each(function () {
var facet = $(this);
var id = facet.data('drupal-facet-id');
var showLessLabel = settings.facets.softLimitSettings[id].showLessLabel;
var showMoreLabel = settings.facets.softLimitSettings[id].showMoreLabel;
- $('').text(showLessLabel).click(function () {
+ $('').on('click', function () {
if (facet.find('li:hidden').length > 0) {
facet.find('li:gt(' + zero_based_limit + ')').slideDown();
$(this).addClass('open').text(showLessLabel);
diff --git a/tests/src/FunctionalJavascript/WidgetJSTest.php b/tests/src/FunctionalJavascript/WidgetJSTest.php
index 51760bd..f390d36 100644
--- a/tests/src/FunctionalJavascript/WidgetJSTest.php
+++ b/tests/src/FunctionalJavascript/WidgetJSTest.php
@@ -74,14 +74,14 @@ public function testLinksShowMoreLess() {
'id' => $id,
'name' => strtoupper($id),
'url_alias' => $id,
- 'facet_source_id' => 'views_page:search_api_test_view__page_1',
+ 'facet_source_id' => 'search_api:views_page__search_api_test_view__page_1',
'field_identifier' => 'type',
'empty_behavior' => ['behavior' => 'none'],
'widget' => [
'type' => 'links',
'config' => [
'show_numbers' => TRUE,
- 'soft_limit' => TRUE,
+ 'soft_limit' => 1,
'soft_limit_settings' => [
'show_less_label' => 'Show less',
'show_more_label' => 'Show more',
@@ -107,7 +107,15 @@ public function testLinksShowMoreLess() {
$block->isVisible();
// Make sure the show more / show less links are shown.
+ $this->createScreenshot('shot.jpg');
$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');
+ $this->drupalGet('search-api-test-fulltext');
+ $this->assertSession()->linkExists('Moar Llamas');
}
/**
diff --git a/tests/src/Kernel/Entity/FacetTest.php b/tests/src/Kernel/Entity/FacetTest.php
index e732ec9..6affc76 100644
--- a/tests/src/Kernel/Entity/FacetTest.php
+++ b/tests/src/Kernel/Entity/FacetTest.php
@@ -66,7 +66,14 @@ public function testWidget() {
$manager = $entity->getWidgetManager();
$this->assertInstanceOf(WidgetPluginManager::class, $manager);
- $config = ['soft_limit' => 0, 'show_numbers' => FALSE];
+ $config = [
+ 'soft_limit' => 0,
+ 'show_numbers' => FALSE,
+ 'soft_limit_settings' => [
+ 'show_less_label' => 'Show less',
+ 'show_more_label' => 'Show more',
+ ],
+ ];
$this->assertEquals(['type' => 'links', 'config' => $config], $entity->getWidget());
$this->assertInstanceOf('\Drupal\facets\Plugin\facets\widget\LinksWidget', $entity->getWidgetInstance());
$this->assertFalse($entity->getWidgetInstance()->getConfiguration()['show_numbers']);