-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New Block: core/tabs #69789
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
base: trunk
Are you sure you want to change the base?
New Block: core/tabs #69789
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
2 similar comments
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @davewhitley, @deborah86. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Alright alright alright, all tests (minus 2 that I'm pretty sure are unrelated to my PR) have passed 😁 and I am ready for people to start reviewing and offer feedback on the new |
Thanks for contributing, @sethrubenstein!
What was an initial version of this? My worry here is that SlotFills are public APIs by default, so anyone who knows their |
@Mamaduka you can view my original comment here: #63689 (comment) Are those slot fills when implemented that way accessible to anyone? I though they had to actually go through exported components in order to be connected properly 🤔 |
Technically, yes. If you know the Example:
I've yet to test this; I was just curious about design decisions. I think it's an interesting challenge, and I'm looking forward to seeing the final result :) P.S. This also reminded me of the Tabs API designs by UI libraries. Example: https://ariakit.org/components/tab. |
That is an interesting point, I hadn't thought of that. I'll try the Symbol method to see if I can get that to work well and get back to you all later in the week. |
That SlotFill key scoping solution worked without issue @Mamaduka, I'll keep that one in mind whenever I need to make a "private" SlotFill. Also, updated the icons so they're in @wordpress/icons proper @Infinite-Null |
@sethrubenstein Not really involved these days in WordPress but every now and then, I glance over the PRs.
If this PR is starting off by admitting that keyboard only users will not have access in the editor, maybe this type of UI doesn't belong in core. Just my two sense without testing everything. Maybe you've thought of a way around this. |
@alexstine Yeah this is something I definitely would like some feedback and testing on. At first I thought my keyboard handlers on the parent block were the only way to go, and they were not firing because of losing focus when I tried to navigate between tabs so I pulled them. I just went back in and changed out the I’m debating changing the frontend elements to be buttons instead of a tags as well if it were not for the href signal? Anyone else have another suggestions on keyboard handlers that should be present that currently are not? |
Seems like the tabs on the front end really don't work with screen readers. Needs to be adjusted to follow spec. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role#example Back-end more or less works now but I don't have time to inspect the code at the moment to see if improvements can be made. FYI @afercia @joedolson |
@alexstine Thanks, I'll get that changed sometime tomorrow. |
I had the wrong aria-role and some unneeded structure, fixed. |
@sethrubenstein This is testing much better now. Nice. |
@sethrubenstein Hi! I'm excited about your PR. I'd be glad to review the design of this, once the conflicts are resolved. |
@davewhitley Thanks! I'll get this merge conflicts resolved on Monday and ping you. |
…ks in favor of static
…ks in favor of static
And I thought, well I'm not actually doing any attributes in the block markup that I wouldn't be aware of so I could make this cleaner and more importantly more effecient.
efad26a
to
598981a
Compare
@davewhitley Merge conflicts are now resolved. |
I have an update regarding some structural changes I'm making to the iAPI implementation to make tabs more extensible for developers. Currently, I'm traversing Each tab block will add its own values, such as The main reason for this change is to enhance extensibility. Now, the interior tab block will generate the tabs list instead of the tabs block itself. This method allows developers to envision new interior sections for tabs while simplifying interaction with the tabs list. All that's necessary for an interior section is to apply some code like this:
To accomplish the following requirements: 1.) add their respective id, label, href link into core/tabs global state, and 2.) wrap their section with
For use in both the tabslist template and the tab sections themselves. These changes are wrapped up in our block library at the moment, I should have time to port them into this PR after WCUS. |
Thanks for picking this up! I'd be happy to review this when you're ready. |
Is it your intention to do something similar to this?
We should look at what happens when there is a client-side navigation to make sure this block is compatible. Maybe we should use Anyway, just something to keep in mind as you move forward with that implementation. |
@luisherranz Good point on the unique id, I'll double check that on client side navigation. Otherwise I'll build a more reproducible id from the tab label slug. Expect another push on this PR with changes to how I'm currently handling the tabs list shortly after WCUS. |
What?
This is Pew Research Center's approach to Tabs in the block editor and would fulfill much of the needs requested in #34079.
This is a new PR picking up where I left off on #69256
This builds upon work started by @creativecoder in #63689 and expands on making this concept even more extensible for developers.
The major changes from this original concept are the following:
core/tab
block will allow it to degrade more gracefully by enabling thecore/tabs
block to control all Interactivity API adoption. If acore/tab
block is displayed outside ofcore/tabs
, it should simply show the tab content without any issues or modifications.Why?
As the block editor and the concept of "full site editing" matures, I'm a strong believer that some basic ui concepts and paradigms should be available in the block library. Tabs is one such basic ui concept, dialog/modals are another.
How?
Testing Instructions
Testing Instructions for Keyboard
On the frontend, simply tab and hit enter to navigate through tabs.
In the editor, unfortunately due to the Slotfill nature of selecting and activating tabs this is currently not possible.(This is now possible by moving the logic into the tab link itself see #69789 (comment))Screenshots or screencast
CleanShot.2025-04-01.at.12.33.39.mp4