Contextual arguments should not be added to tab links routeParameters

Created on 6 September 2024, 4 months ago
Updated 19 September 2024, 3 months ago

Problem/Motivation

In a view with tree pages and each one with its glossary attachment, the argument passed to the query by the glossary is added to the local tabs thus making local tabs useless

Steps to reproduce

Create a views page listing all nodes of some selection. don't enable Ajax because with ajax you can not see the real url on the browser (but google sees it anyway)

Settings:

- A -

  1. Path: 'my_page'; Menu: Type 'Default menu tab', Menu link title 'All'; Parent menu link 'Already exists'
  2. Contextual filter with content title, in More enable Glossary mode, Character limit to 1
  3. Create an attachment with Contextual filter 'content title',
  4. When the filter value is NOT available: Display a summary, Base path: 'my_page' (same as the menu), in More enable Glossary mode, Character limit to 1
  5. Attachment position: Before; Inherit contextual filters: No.
  6. Attach it to the page 'my page
  7. Enable Ajax in both page and attachment
  8. You now have they machine_names 'page_1' and 'attachment_1'

This is a setting to have a glossary and a sub-selection by starting letter.

- B -
Duplicate both page and attachment, they will be with machine_name 'page_1' and 'attachment_1'
Add an extra filter to the new page, change its path to 'my_page/selection1', set its Menu from 'Default menu tab' to 'Menu tab' and the Menu link title from 'All' to 'Selection1'. In contextual filters change Base path to 'my_page/selection_1'
Same with the new attachment. Change the new attachment to point to the new page

- C -
Duplicate "A" like in "B": change paths to 'my_page/selection_2', Menu link title from 'All' to 'Selection2', etc.

- D -

Display the page on path 'my_page'. You can see
three tabs ----- All ----- |------- Selection1 ------- | ----- Selection2 ---------
linked to "my_page" | "my_page_selection1 | "my_page/selection2"

On the browser address bar add a search argument to the url, let's say "my_page/selection1/k" (remember we use a glossary to select node titles by a starting letter)
Result: Inspect the tab urls,
they became "my_page/k" | "my_page/selection1/k" | "my_page/selection2/k"
So clicking the tabs you can no more access to "my_page" | "my_page/selection1" | "my_page/selection2" which was the expected behavior.

Proposed resolution

I didn't dig into the code but I used hook_menu_local_tasks_alter to loop through tabs and reset url without the extra argument produced by the glossary.
$data['tabs'][$index][$tab_key]['#link']['url']->setRouteParameter('arg_0', NULL);

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡«πŸ‡·France erwangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @erwangel
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    I'm not sure what will break if we don't add this, but probably something

    This feels very familiar but can't find the issue this makes we think of.

    The described use case sounds VERY niche, if this is the only way to trigger this, it will probably require a very focussed fix in order not to create any regressions.

Production build 0.71.5 2024