Open klonos opened 9 years ago
Notice how both the "Find content" tab as well as the "Node detail" tab are shown with white background, as active, no matter which one is chosen. They both get class="active"
, so perhaps we should generalize this as a "Make sure only one local task tab is active at a time"?
The active state is determined by the menu system, and is usually determined by path. Sanity check: @klonos Are you sure both displays have unique paths?
If so, this might be a bigger problem, having nothing to do with design.
You can get into this situation when setting more than one displays of the same view to be a "Default menu tab":
...OK, so this seems to occur if both displays have the same "parent path". So for example, if you clone the "Page" display of the "Administer content", you get a page that has the same path (/admin/content/node
), and is also set to be a "default tab". This is one common way to cause the problem.
Even after you edit the path of one of the displays and change it to /admin/content/another-node
, you get the same issue.
If you change the path to /admin/content/another/node
or to /completely/different/path
, the issue does not happen of course.
I have started working on a fix on my local, and I have gotten to a point where the "default menu tab" option is disabled when adding new displays if there is already a display -within the same view- which has been set to be the default menu tab:
Now I need to figure out if it is viable to also get the menu path into play, and to also search across displays of different views.
...the logic started getting too complicated, and I have thought of (edge perhaps, but still legitimate) use cases where one might want to actually set more than one displays as default menu tabs in the same view, and the same path (they might want to later limit access based on user permission/role for example).
So I am now thinking to try to tackle this during rendering of the tabs. So the active
class should be set to only the tab that has a path that matches the current path. This should sort the problem in a less "expensive" way I believe. I'll give that a go.
...this seems to be related to https://www.drupal.org/project/drupal/issues/2804195
Views: Creating a second display of the same view and setting it as a default menu tab shows all menu tabs by that view as active.
Also noticed while replying in https://github.com/backdrop-ops/contrib/issues/114