pymdown-extensions icon indicating copy to clipboard operation
pymdown-extensions copied to clipboard

Ability to focus on a given tab in a tab set.

Open UltraInstinct05 opened this issue 2 years ago • 7 comments

Description

Currently, there is no way to focus on a given tab (among tabs). The first tab always gets the focus. It would be nice if there was a way to put focus on a specific tab.

Relevant mkdocs-material discussion https://github.com/squidfunk/mkdocs-material/discussions/3982

Benefits

One use case I have is described here https://github.com/squidfunk/mkdocs-material/discussions/3982#discussioncomment-2881853

Solution Idea

One possible solution using ===+ is described here https://github.com/squidfunk/mkdocs-material/discussions/3982#discussioncomment-2881832

UltraInstinct05 avatar Jun 04 '22 05:06 UltraInstinct05

@gir-bot remove S: triage

facelessuser avatar Jun 04 '22 05:06 facelessuser

It appears the new tab select feature will be incompatible with MkDoc Material's content.tabs.link feature. @squidfunk FYI.

Material will try and normalize link selection on page load.

facelessuser avatar Jun 04 '22 15:06 facelessuser

This would normally be fine if the normalization occurred after a tab was manually selected on a page, but I think Material just does this all the time, and does it across pages as well. So if you select a tab on one page, the next page will auto select what was selected on the previous pages.

facelessuser avatar Jun 04 '22 15:06 facelessuser

Somehow related to #1766. If we could identify manual focus on a content tab section, we could detect an author-provided override and skip the content.tabs.link feature for that tab group.

squidfunk avatar Jul 30 '22 10:07 squidfunk

I already have a PR open that adds specifying focus in #1725, it is not limited by the need of attribute lists as much as it is limited by the inability to use it in MkDocs Material due to conflicting features.

facelessuser avatar Jul 30 '22 12:07 facelessuser

In general, we need something discernable to detect user overrides. As I understand, Tabbed will always set checked for the first tab right? Thus, if another tab is set to active, we could skip the linking logic altogether. This would however not work for the first tab, i.e. if the user adds + to the first tab. In that case we would need something else that tells us "don't link, override in place".

squidfunk avatar Jul 30 '22 13:07 squidfunk

We could always add some CSS class to note the tab was forced to a linking. Though, I would argue that the problem is really only important on the initial page load. A user may want to force a default, but once a tab is selected, tab syncing could also begin. Or maybe not, I'm just thinking out loud here.

facelessuser avatar Jul 30 '22 15:07 facelessuser

I will be merging this feature in. I do not have a solution for Material to determine if a tab is manually selected. I am open to a well thought out proposal though. I do not view the lack of such functionality as a bug, but an enhancement only for projects that attempt to remember tab select states across pages and/or initialize tab select states on page load, for all other cases, things should work fine.

facelessuser avatar Oct 16 '22 14:10 facelessuser

Note that there're now anchor links for content tabs, which might also conflict.

squidfunk avatar Oct 16 '22 15:10 squidfunk

It shouldn't conflict with the feature, but I'll double check that I have accounted for it properly in the logic.

facelessuser avatar Oct 16 '22 15:10 facelessuser

Oh, I see, it's a feature to adjust the URL so you can share a link to a tab. In this case, even if it overrides the user's set default, in this case, it would make sense. If you are using a URL to navigate to a specific tab, I would expect it to take priority.

facelessuser avatar Oct 16 '22 20:10 facelessuser