-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabs: consider simplifying edge case handling #66011
Comments
Some more thoughts:
|
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? |
I'll do my best, but it may be tricky since these behaviors track back to the legacy 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.
Opened ariakit/ariakit#4213 to bring this behavior to the attention of |
Update: With #66097 merged, the only bit of custom logic left is related to the conversation happening in ariakit/ariakit#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
The text was updated successfully, but these errors were encountered: