Open ciampo opened 1 month ago
Some more thoughts:
#1
feels arbitrary. I guess that this could be delegated to the consumer of the component, if they even find themselves in this scenario;#2
: why can't a selected tab that becomes disabled stay selected? If that's problematic, I guess it's another situation in which the consumer of the component could handle the edge case;#3
and #4
are potentially addressed in ariakit with this update; if the selectedid
gets out of sync, could we also assume that the responsibility should fall on the consumer of the component?#5
looks like the most reasonable, almost a bug fix. We'd need to look into it and understand when / why it was needed, and if we still need it.Thanks for the details 👍
I agree with your proposal 👍 It's worth auditing the reasons behind introducing all of these custom edge cases, and if there's no clear good reason, we should just clean them up and go with the defaults.
Any arguments to support not going that way?
It's worth auditing the reasons behind introducing all of these custom edge cases
I'll do my best, but it may be tricky since these behaviors track back to the legacy TabPanel
component and may be the result of several iterations over the years.
I'll do my best, but I'm also tempted to remove all the hooks and see what e2e tests break + smoke test the tabs in the editor.
@ciampo fully support this and your proposed approach in the last comment. I think when/if the need for those behaviors pops up again after the clean-up, when should probably take the route of reporting to ariakit first as bugs or feature proposals.
I opened #66097 to remove the custom logic.
- behaviour
#5
looks like the most reasonable, almost a bug fix. We'd need to look into it and understand when / why it was needed, and if we still need it.
Opened https://github.com/ariakit/ariakit/issues/4213 to bring this behavior to the attention of ariakit
authors
Update: With https://github.com/WordPress/gutenberg/pull/66097 merged, the only bit of custom logic left is related to the conversation happening in https://github.com/ariakit/ariakit/issues/4213
The private
Tabs
component has a bunch of custom logic that handles a few edge cases:defaultTabId
is specified,Tabs
will select an initial tab only if there is a tab matchingdefaultTabId
. If there isn't a matching tab,Tabs
won't have an initially selected tab. If a tab with a matching id is added lazily,Tabs
will select it.Tabs
component won't have any selected tab;Tabs
assumes that the consumer of the component is in charge of the situation, and therefore it un-selects the previously active, now disabled tab;Tabs
falls back to thedefaultTabId
if possible. Otherwise, it selects the first enabled tab (if there is one).Tabs
will reset the active tab id (ie. no tabs are active) if a tab associated to the currently selected ID can't be foundThis custom logic was originally added after observing how the legacy
TabPanel
component worked, in an effort to cover all edge cases found when using the component in the editor.As the
ariakit
library updates and we iterate on the component I am considering removing most (if not all) of this custom logic:ariakit
's latest changes should make sure that a composite widget (like tabs) is always somewhat tabbable, even if the active/selected ID doesn't match an existing DOM element;Tabs
focused on providing good tab widgets fundamentals;My instinct is to remove as much of this code as possible (ideally all of it):
Tabs
is consumed, if necessary;@WordPress/gutenberg-components , I'd like to hear your thoughts on this proposal