It appears this is not related to the issue as was assumed in (#1 - #11):
PathMatcher::isFrontPage() does not work for the default homepage if it contains a query string.

I have tested this with a small block that displayed the value of PathMatcher::isFrontPage(), but it also appears to affect the menu system (where I first noticed this):

Issue since #12:

When appending a query string to a URL, the active trail is no longer added. This is undesirable because queries might be added for tracking a user's entrypoint eg example.com?referrer=email or pagination on a page (the second page of the menu item is still in the active trail of the menu item).
These situations will make that you see the home page, but it is not marked as active.

Reproduce:

  1. Visit the regular front page of your Drupal site: example.com.
  2. Append a query string to the url: example.com?foo=bar.
  3. Notice that the home menu item no longer has the is-active class.
  4. Then repeat the same test with JavaScript disabled in development console and not being logged in. Notice the same behavior.

I could only achieve above behavior with the home page (example.com?foo=bar and example.com/node?foo=bar) and all other paths work as expected, so there appears to be something wrong with this default front page path somehow.

This appears not to be only limited to the home page anymore. Appending a query string to other pages also makes they are no longer marked active.

Before:

After patch #42:

CommentFileSizeAuthor
#85 2845319-85.patch3.35 KB_utsavsharma
#85 interdiff_84-85.txt1.5 KB_utsavsharma
#84 2845319-84.patch2.88 KBcasey
#80 interdiff_79-80.txt716 bytesjuanolalla
#80 2845319-80.patch2.65 KBjuanolalla
#79 interdiff_78-79.txt4.07 KBbnjmnm
#79 2845319-79.patch2.66 KBbnjmnm
#78 2845319-78.patch2.9 KBjuanolalla
#77 interdiff_76-77.txt1.12 KBAkram Khan
#77 2845319-77.patch14.28 KBAkram Khan
#76 interdiff_75-76.txt3.93 KBAkram Khan
#76 2845319-76.patch14.27 KBAkram Khan
#75 2845319-75.patch13.87 KBdouggreen
#73 2845319-73.patch16.97 KBdouggreen
#72 interdiff_69-72.txt1014 bytesNitin shrivastava
#72 2845319-72.patch20.6 KBNitin shrivastava
#70 2845319-nr-bot.txt2.79 KBneeds-review-queue-bot
#69 interdiff-68_69.txt3.88 KBGauravvvv
#69 2845319-69.patch20.63 KBGauravvvv
#68 2845319-68.patch20.76 KBGauravvvv
#67 2845319-nr-bot.txt85 bytesneeds-review-queue-bot
#65 2845319-65.patch19.47 KB_utsavsharma
#65 interdiff_64-65.txt1.04 KB_utsavsharma
#64 2845319-64.patch19.6 KBArtusamak
#58 2845319-after_patch-MR_866.png733.3 KBAbhijith S
#58 2845319-before_patch-MR_866.png728.88 KBAbhijith S
#54 2845319-54.patch23.8 KBjuanolalla
#43 Screenshot 2021-06-06 at 08.22.41.png208.93 KBGauravvvv
#43 Screenshot 2021-06-06 at 08.20.59.png189.89 KBGauravvvv
#42 interdiff-39-42.txt289 bytesjungle
#42 2845319-42.patch1.16 KBjungle
#39 interdiff_2845319_38-39.txt421 bytesankithashetty
#39 2845319-39.patch1.29 KBankithashetty
#38 interdiff_2845319_37-38.txt531 bytesankithashetty
#38 2845319-38.patch1.29 KBankithashetty
#37 the_menu_home_tab-2845319-37.patch1.27 KBimot3k
#23 the_menu_home_tab-2845319-23.patch1.07 KBdanylevskyi
#17 the_menu_home_tab-2845319-17.patch630 bytesNeograph734
#14 PathMatcher_query_strings-2845319-14-fail.patch5.29 KBPavan B S
#7 PathMatcher_query_strings-2845319-7-fail.patch5.49 KBNeograph734

Issue fork drupal-2845319

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Neograph734 created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dawehner’s picture

Issue tags: +Needs tests

One thing you could do is to try to write a test case. core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php already contains a bunch of tests for this class.

Neograph734’s picture

I will have a look. Thanks.

Just to be sure, I first write a test that is supposed to fail, and then a patch so the test passes again right?

dawehner’s picture

Just to be sure, I first write a test that is supposed to fail, and then a patch so the test passes again right?

That would be ideal indeed.

Neograph734’s picture

Assigned: Unassigned » Neograph734

Right, I'll see what I can do.

Neograph734’s picture

Title: the PathMatcher::isFrontPage() function does not respect query strings » the PathMatcher() does not respect query strings and fragment identifiers
Status: Active » Needs review
FileSize
5.49 KB

So I think that paths containing query strings or fragment identifiers should actually be considered equal to paths without. Attached patch adds checks for query strings and fragment identifiers. This one should fail.

Changed the name a little, since a local test turned out this was not strictly related to the front page.

Status: Needs review » Needs work

The last submitted patch, 7: PathMatcher_query_strings-2845319-7-fail.patch, failed testing.

Neograph734’s picture

Component: routing system » menu system

Hmm, after attempting to patch the above issue (by attempting to strip everything after the ? from the url). It appears this is not coming from PathMatcher->matchPath().
In fact, it seems that the PathMatcher including the isFrontPage() function are working as expected now. But the menu active trail is still not recognized.

It seems to be even weirder though. The is-active class on the home menu-item is added later via JavaScript or something? The raw data from the page looks like this:

<ul class="clearfix menu">
  <li class="menu-item">
    <a href="/" data-drupal-link-system-path="<front>">Home</a>
  </li>
  <li class="menu-item">
    <a href="/node/1" data-drupal-link-system-path="/node/1">Test</a>
  </li>
</ul>

But in Development console it looks like this:

<ul class="clearfix menu">
  <li class="menu-item">
    <a href="/" data-drupal-link-system-path="<front>" class="is-active">Home</a>
  </li>
  <li class="menu-item">
    <a href="/node/1" data-drupal-link-system-path="/node/1">Test</a>
  </li>
</ul>

There is also a quick flash on the menu item when loading a page. (All caches are disabled using this method: https://www.drupal.org/node/2598914)

Apparently this JavaScript (what else could it be) is only matching the exact url and does not take query parameters into account? Can someone confirm this?

Neograph734’s picture

Neograph734’s picture

Title: the PathMatcher() does not respect query strings and fragment identifiers » The menu 'Home' tab does not respect query strings and fragment identifiers
Neograph734’s picture

Status: Needs work » Active

After disabling JavaScript in the Development Console, the home tab indeed no longer lights up. This means there is nothing in the menu system adding the class to "Home".

Which makes this related to #2641198: "Home" menu-item is missing li.menu-item--active-trail class and #1578832: Class active-trail not added to li element when linking to front page.

Neograph734’s picture

Assigned: Neograph734 » Unassigned
Status: Active » Needs review

This appears to be coming from the following line in core/misc/active-link.js:

selectors = selectors.map(function (current) { return current + querySelector; });

If the is a query string provided in the url field, Drupal assumes that the query string should also exist on the link that rendered the page. All links to the same path, but without the query string will not get activated. In my opinion, this should look more like the following, where the selectors contain both versions, with and without query string:

selectors = selectors.concat(selectors.map(function (current) { return current + querySelector; }));

But then in the end, it still feels very strange this needs to be done with JavaScript. I'd assume that the menu system would be capable of adding a class to a link.

Pavan B S’s picture

Rerolled the patch, please review

Status: Needs review » Needs work

The last submitted patch, 14: PathMatcher_query_strings-2845319-14-fail.patch, failed testing.

Neograph734’s picture

Thanks Pavan,

But the problem is not within the PathMatcher(). It is in 'core/misc/active-link.js'. See #13.

Neograph734’s picture

Neograph734’s picture

Issue summary: View changes
Neograph734’s picture

Issue summary: View changes

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Neograph734’s picture

Issue tags: -Needs tests

I am removing the 'needs tests' as this is not a core system failure, but just a wrong javascript selector. Let's see if the patch still applies.

danylevskyi’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
danylevskyi’s picture

Status: Needs work » Needs review
FileSize
1.07 KB
Neograph734’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Yes, this seems to work!

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks @Neograph734 and @danylevskyi.

We do have the ability to write automated tests exercising JavaScript; see JavaScriptTestBase and https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutorial. So, setting back to "Needs work" and re-tagging for an automated test to be written.

@Pavan B S, I've removed credit for the reroll in #14 because it was indicated in comments after #7 that it was no longer the correct approach. Please read the issue comments before submitting patches.

Neograph734’s picture

@xjm, would it suffice to write a test that simply fetches example.com?foo=bar and example.com?foo=bar&bar=baz and then validates that the home tab is highlighted? Or should we include other cases as well (and which ones)?

Neograph734’s picture

Title: The menu 'Home' tab does not respect query strings and fragment identifiers » The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers
Issue tags: -Needs tests

I am a bit confused... In core/misc/active-link.es6.js the top reads the following:

* Append is-active class.
*
* The link is only active if its path corresponds to the current path, the
* language of the linked path is equal to the current language, and if the
* query parameters of the link equal those of the current request, since the
* same request with different query parameters may yield a different page
* (e.g. pagers, exposed View filters).

So that means the current behavior would be the desired behavior.

Also my prior statement that this does only affects the 'Home' menu item is untrue. Exactly as the above description states the is-active class is only added to menu items with matching query parameters. However this is not visible at first glimpse as all other menu items do have the menu-item--active-trail class, so they do appear with a highlighted menu tab.

So I dug in the history of active-link.js and figured out that it was created as part of #1979468: ".active" from linkGenerator(), l() and theme_links() forces an upper limit of per-page caching for all content containing links. Short summary:

HTML links generated by either l(), theme_links() or linkGenerator() all dynamically check whether they are currently "active" by comparing the current URL's structure against the parameters being used to construct the link tag. This "active" class is used very commonly by themers to provide visual cues for users navigating the site, and there is no "browser native" or other CSS equivalent - this functionality can't be achieved without modifying the DOM.

The problem is that we cannot cache these links with any better granularity than "per page". Ideally, we would want to be able to cache links globally as link generation functions can be called hundreds of times on each page load and most sites would get a decent cache "hit rate" as it's very common for the same link to be shown on multiple pages in a site.

However, it seems that the caching problem has been resolved in MenuActiveTrail::getActiveTrailIds:

This implementation caches all active trail IDs per route match for *all* menus whose active trails are calculated on that page. This ensures 1 cache get for all active trails per page load, rather than N.

So if I understand everything well, we can conclude that active-link.js is effectively no longer needed because the menu-link--active-trail covers the same highlighting. (Removing it would involve a change record that themers should replace is-active with menu-item--active-trail?) Or we do implement the patch from #23, but then it should also be tested what happens if a menu item links to the second page of a paged view. It should not light up for the first page, as explained on the top.

The actual issue is that the 'Home' menu item does not get the menu-item--active-trail class assigned because it is not considered to be part of the active trail.

I would really like a maintainer to chime in here and share some thoughts on this before I start taking any more actions. Is there some tag to request maintainer feedback or something?

Neograph734’s picture

I hope this is the right tag to draw some attention to this issue, for as I am stuck.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rahul01’s picture

Assigned: Unassigned » rahul01
rahul01’s picture

Assigned: rahul01 » Unassigned
sumitmadan’s picture

Adding to @Neograph734's comment, I'm not sure why it is implemented this way, but, adding an active class to link based on query parameters, seems a very rare case.

Also, patch in #23 resolves the issues for authenticated users only. For the anonymous user, "ActiveLinkResponseFilter" class is used to set "is-active" class to link.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

RedLucas25’s picture

I also want to add to this that I think it is fair to expect the active-link to not be query string dependent.

It's been two years since this has been touched from the looks of it. I just now have run into an issue that is resolved by #23. (authenticated user problem).

I'll be implementing the patch, but I'd much prefer about seeing a solution make it into core.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

imot3k’s picture

ankithashetty’s picture

Just fixing the custom command failure errors in #37, thanks!

ankithashetty’s picture

Fixing the custom command failure errors, thanks.

Yago Elias’s picture

Version: 8.9.x-dev » 9.1.x-dev

Patch #39 worked for me on Drupal 9.1.7.

Links are now highlighted when accessing the page with a query string.

Yago Elias’s picture

Status: Needs work » Reviewed & tested by the community

Changing status of the to RTBC.

jungle’s picture

Version: 9.1.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests, +Bug Smash Initiative
FileSize
1.16 KB
289 bytes

Re #39, .js files should be generated by running the following commands:

$ cd core
$ yarn
$ yarn build:js

I am afraid this one would not get committed without tests added as this is a bug, tagging back Needs tests. Also tagging Bug Smash Initiative. The current active dev version is 9.3.x-dev.

Gauravvvv’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
189.89 KB
208.93 KB

Now is-active class is available after using ?foo=bar after the URL on the homepage.

I have added before and after patch screenshot for reference.

Moving to RTBC.

Gauravvvv’s picture

Issue summary: View changes

Updated IS

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs committer feedback

Committers do not monitor the "Needs committer feedback" tag, so no use adding it. :) (You probably figured that out since no one replied for years.) We monitor tags for our individual roles ("Needs release manager review", etc.), or the RTBC status.

This seems a reasonable change to me; however, we still need test coverage for it. (The manual testing and screenshots were helpful! But we also need an automated test.) It's also worth noting that (as described in #27), this sounds like it was working as documented. If we're changing the behavior to allow any query string to be highlighted, should we also update the docs?

Thanks!

Neograph734’s picture

Issue summary: View changes

@xjm, I had figured something by now :). But thanks for at least confirming that the proposed behavior makes sense. If a query string is used in pagination for a second 'page' on the home page, I suppose it is still the home page.

When searching for the test, I also ran into ActiveLinkResponseFilter. And I think that might need updating as well (as well as its test ActiveLinkResponseFilterTest). This class is actively checking if the query matches with the element's data-drupal-link-query attribute, which might not be defined.
After disabling Javascript in the developer console, the behavior can be observed so there is is also a non-javascript part adding the is-active class for anonymous users too! (Summary updated.)

As for test of the active-link.js JavaScript, I cannot seem to find any existing test?

Neograph734’s picture

Issue summary: View changes

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

bnjmnm’s picture

Status: Needs work » Needs review
jenlampton’s picture

Title: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers » The highlighting of the active menu-link does not respect query strings and fragment identifiers

Updating issue title.

nod_’s picture

Issue tags: +JavaScript
juanolalla’s picture

Status: Needs review » Needs work

This needs a reroll, core/modules/system/tests/src/Functional/Common/UrlTest has changed: "Merge blocked: fast-forward merge is not possible. To merge this request, first rebase locally."

juanolalla’s picture

Status: Needs work » Needs review
FileSize
23.8 KB

Rerolled merge request. Attaching updated patch.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Drumanuel’s picture

Patched 9.4.2 with 2845319-54.patch, looks good

Abhijith S’s picture

Applied MR 866 on 9.5.x and it works fine.The is-active class is appearing even when the query strings are present, after applying this patch.

Before patch:

After patch:

Neograph734’s picture

Status: Needs review » Reviewed & tested by the community

Setting RTBC based on #56 and #57. Thanks for testing.

balazswmann’s picture

I can also confirm that the patch in #54 works with 9.3.21. Thanks!

Gauravvvv’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

There are some suggested changes from @bnjmnm and also we will need a 10.x version of the MR because there are no longer .es6.js files and JS standards have been tweaked slightly no we don't have to support IE.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Artusamak’s picture

_utsavsharma’s picture

FIxed CCF for #54 for 9.5.x.
Please review.

gidarai’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
85 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Gauravvvv’s picture

Status: Needs work » Needs review
FileSize
20.76 KB

Added patch for 10.1.x. please review

Gauravvvv’s picture

Fixed CCF, attached interdiff for same.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
2.79 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

douggreen’s picture

Issue tags: -JavaScript +JavaScript

This line needs parenthesis to clarify the logic:

if (!isset($query) || empty($query) || $node->getAttribute('data-drupal-link-query') !== Json::encode($query) && !empty($node->getAttribute('data-drupal-link-query'))) {

But really what it needs is simplification IMO, maybe something like:

$attribute = $node->getAttribute('data-drupal-link-query');
if ($attribute && attribute != Json::encode($query ?? [])) {
Nitin shrivastava’s picture

Try to fix error.

douggreen’s picture

Having a merge request and the patch is confusing. I've tried to sort out which is newer, I think that the patch is newer. The merge of 9.3.x by @Juan and the merge of 9.5.x by me complicate the history. I suggest that we start over with the current patch 72.

The attached patch

  • is based on 2845319-72.patch
  • is updated it to use es6, and has a complied version of the js changes
  • rolled back the logic changes in ActiveLinkResponseFilter.php because the current logic is clearly faulty and it's unclear why this was introduced in #54. I'm unclear if this was a fix or code cleanup. I'd appreciate @juanolalla's comments on that
juanolalla’s picture

In #54 patch I just re-rolled the merge request, I don't know who/when/why that logic changed in ActiveLinkResponseFilter.php at some point. As long as ActiveLinkResponseFilterTest.php is testing the logic well and the patch passes tests we are fine.

#73 patch is failing to apply. Does it target 10.1.x?

douggreen’s picture

FileSize
13.87 KB

#73 is for 9.x

Here is a patch for 10.x (the primary change is [#3305487], but this needs review to ensure I resolved the conflicts properly).

Akram Khan’s picture

added updated patch and fixed CCF of #75

Akram Khan’s picture

juanolalla’s picture

I'm uploading a new patch with just the changes to active-link.js. I think this is going to pass tests, and I'll explain why.

I'm removing the changes to ActiveLinkResponseFilterTest and UrlTest. They fail because there is no related implementation on php, which is what they are testing. They are testing the logic in ActiveLinkResponseFilter, that hasn't change at all. So it make no sense to change the testing logic without changing the code being tested.

So, as we have seen from the beginning, there are different places where the logic that states that a URL with query parameters is not the same as without or different query parameters in terms of marking links as "active", has been implemented, on the backend code, and with JavaScript. We are fixing this just in the JavaScript layer, and with that change, tests don't fail. That means that there is no JavaScript tests in core right now checking that the links shouldn't have the 'is-active' class when not matching query parameters.

So, to do this right, in my opinion, we should discuss if we are agreed that the current logic is not right: all same url with different query parameters combinations (with the same language), should be treated as the same in terms of marking is as active.

Then, if we agree on that and this issue makes sense, we should create JavaScript testing cases for the new logic (there isn't any for the current logic at this level).

And then, we should rewrite the PHP code as well, and so for the tests managing that. Why do we have both PHP and JavaScript implementation? I would love to know.

bnjmnm’s picture

#78 looks good - this just gets rid of a bit of repetition and concat() uses.

juanolalla’s picture

Patch #79 wasn't working, the is-active stopped appearing (and tests failed). JSON.stringify() was adding double quotes, so we ended up having double quotes within double quotes in the queryMatchSelector string variable.

Fixed in this patch #80. Adding interdiff.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

douggreen’s picture

The test form earlier patches was lost, and need to be restored.

juanolalla’s picture

@douggreen please see #78 above, where I explained the problem I found with tests (tldr: wrong tests, js tests don't exist yet for this in core)

casey’s picture

Status: Needs work » Needs review
FileSize
2.88 KB

Just run into this issue as well. What about only checking the query arguments from data-drupal-link-query and only skip if any of those don´t match the current query, while ignoring any additional query arguments from the current query.

_utsavsharma’s picture

Tried to fix the CCF in #84.

Status: Needs review » Needs work

The last submitted patch, 85: 2845319-85.patch, failed testing. View results

John Pitcairn’s picture

Using patch #80 against 10.2.3 allows local task tabs to highlight as active if there is any added url query.

I have not tested what happens if the local task target url itself contains a query. In that case the behaviour should probably be to match the local task specific query parameter(s) and only highlight as active if the task url query parameters match, ignoring added query parameters. @casey is this what #84 is attempting?