Problem/Motivation

The facet block should use the facet label as the title instead of using the facet source and facet name to create a title.

Steps to reproduce

This only happens after updating the facet module to 2.0.6 and block facet to 1.5.0

Proposed resolution

Update the face title in the block to use the label of the facets.

Comments

ashrafomar created an issue. See original summary.

ashrafomar’s picture

ashrafomar’s picture

StatusFileSize
new560 bytes
pianomansam’s picture

Version: 8.x-1.05 » 2.0.x-dev
Status: Needs review » Reviewed & tested by the community

This fixed the issue for me on 2.0.0-beta1. I'm bumping this issue to 2.x-dev because that's the latest version. However, it can be backported at the current time as well.

gnikolovski’s picture

Status: Reviewed & tested by the community » Needs work

Using translations like this is not recommended:

$this->t($block_plugin->label())

Only string literals should be passed to t().

We need to change this.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new551 bytes

Added patch by addressing #5, please review it.

alexp999’s picture

It's been caused by 3255460

For some reason the facet title had the source added, really unnecessary and broken front end UI

nord102’s picture

Re-rolled the previous patches to use the $block_plugin->label() and translate it properly.

b_sharpe’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #6 is correct, Patch #8 is unnecessarily translating a variable that should already handle it's own translation, there is no reason to pass this through t() unless there was some prefix/suffix text here.

jonathan_hunt’s picture

Patch #6 is working for me, thanks.

yorder.be’s picture

StatusFileSize
new449 bytes

This doesn't seem to work with translations.
This seems to work.

aelfendir’s picture

Patch #11 worked perfectly in our project (D10.1.4) to fix an issue with translations. Thanks!

gnikolovski’s picture

Assigned: Unassigned » gnikolovski

gnikolovski’s picture

Status: Reviewed & tested by the community » Fixed

Fixed.

Patch #11 applied, since it works with translations as well (I just tested it).

jonathan_hunt’s picture

Unfortunately the change in patch #11 as released in 2.0.0-beta3 fails in the case of drupal/facets_range_dropdowns since $build['0']['#facet'] is not set. For now, I am using

if (isset($build['0']['#facet'])) {
  $title = $build['0']['#facet']->getName();
}
else {
  $title = $block_plugin->label();
}

$facets[] = [
  '#block_plugin' => $block_plugin,
  'title' => $title,
  'content' => $build,
  'attributes' => new Attribute($build['#attributes']),
];
gnikolovski’s picture

Fixed the issue in #16 and released 2.0.0-beta4.

jonathan_hunt’s picture

Thanks for that, working for me via 2.0.0-beta4.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.