Drupal Version: 9.2

Domain module version: 1.0.0-beta6

Expected Behavior

An active class on link of current domain in domain_nav_block block with the Unordered list of links (ul) option

Actual Behavior

No class

Steps to reproduce

* Place DomainNavBlock in your page
* Configure it with "Unordered list of links" (ul) option as "Link theme"
* visit homepage

Issue fork domain-3226519

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

SylvainM created an issue. See original summary.

sylvainm’s picture

Assigned: sylvainm » Unassigned
Status: Active » Needs review
dqd’s picture

Awesome work. +1 Will review later.

agentrickard’s picture

Status: Needs review » Needs work

This PR should update domain/tests/src/Functional/DomainNavBlockTest.php

sylvainm’s picture

Status: Needs work » Needs review
agentrickard’s picture

Status: Needs review » Needs work

Minor code style issue -- we use

if ()  {
}
else {
}
sylvainm’s picture

Status: Needs work » Needs review

Fixed, thanks!

tim-diels’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work

This should be targeted towards the 2.x branch.

tim-diels’s picture

Status: Needs work » Reviewed & tested by the community

I've tested the code and it works as expected, so for me it is RTBC. I created a new MR against 2.x with same code and tested it.

dqd’s picture

Status: Reviewed & tested by the community » Needs work

Please do not set RTBC by own patches without review of others.

Again: Thanks for the report and the work in here. Very much appreciated. But some nitpics:

-          $items[] = ['#markup' => Link::fromTextAndUrl($label, $url)->toString()];
+          if ($domain->isActive()) {
+            $url->mergeOptions(['attributes' => ['class' => 'active']]);
+          }
+          $items[] = [
+            '#type' => 'link',
+            '#url' => $url,
+            '#title' => $label,
+          ];

These changes do not only add active class in case of $domain->isActive() but also change/replace the ['#markup' => Link::fromTextAndUrl($label, $url)->toString()]; to an $items[] array without Link::fromTextAndUrl() without documentation in the issue comments. This should be documented and explained even if obvious for the patch provider, so that follow up issues can better be tracked down and find its root causes.

tim-diels’s picture

I only added the code that was already provided. but fair enough I follow that I can not set own patches/MR as RTBC.

What do you need from us to continue in this issue? Some sort of CR so everybody knows what happend and that can be linked in this issue and in the release notes? Or were you thinking about something else?

davps made their first commit to this issue’s fork.

davps’s picture

Status: Needs work » Needs review

I rebased MR #75 from the current master branch, simplified fix and rewrote the case for testing.

agentrickard’s picture

Status: Needs review » Needs work

Looks good but needs to be rebased.

Fixing.

agentrickard’s picture

Status: Needs work » Reviewed & tested by the community

agentrickard changed the visibility of the branch 3226519-navigation-block-with-active-class to hidden.

agentrickard changed the visibility of the branch 3226519-navigation-block-with-active-class to hidden.

agentrickard’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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