-
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
Convert Media Inserter to Tabs Pattern #60970
Conversation
Size Change: -405 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
@ntsekouras - I need to write the PR description and do some cleanup, but it's ready for some initial testing. |
Love to see all the removed code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @jeryj! I checked the code and tested and this feels almost ready.
A couple of issues to address though.
- We need to have the
Open media library
button at the bottom of the content. I'll cc @jameskoster for this and any input for the style changes he might have.
- There is an issue with keyboard navigation when we have selected a category, either in patterns or media. In that case we cannot get to the
Open media library
orExplore all patterns
. I think this has regressed for patterns in the first previous similar PR to use tabs.
Agree it probably makes sense to mimic the position on trunk for now. I appreciate the updated metrics of the category buttons! |
The Open media library and Explore all patterns buttons are positioned after the tab panels. You have to tab through the panel to reach the button. If there's no tab panel open, then it's the first tab stop after the category tabs. I think this is the best balance given the semantics and design, even though I do agree it feels unnatural when the category tab panel is open. The alternative is worse (having the button tab stop between the tabs and tab panel). |
Flaky tests detected in edd6ad6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8802841934
|
Fixed to match Trunk. I do think it's less noticeable when it's pushed to the bottom of the sidebar though. |
const container = useRef(); | ||
useEffect( () => { | ||
const timeout = setTimeout( () => { | ||
const [ firstTabbable ] = focus.tabbable.find( container.current ); | ||
firstTabbable?.focus(); | ||
} ); | ||
return () => clearTimeout( timeout ); | ||
}, [ category ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-focusing from a tab selection isn't a normal flow, so we can remove this interaction which simplifies things.
|
||
const { Tabs } = unlock( componentsPrivateApis ); | ||
|
||
function CategoryTabs( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both components share so much code, it made sense to refactor this.
[ | ||
setSelectedPatternCategory, | ||
__experimentalOnPatternCategorySelection, | ||
isZoomedOutViewExperimentEnabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter caught a missing dependency
onHoverPattern, | ||
onInsertPattern, | ||
onClickPatternCategory, | ||
patternFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing dependencies from linter
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 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. |
This includes a lot of refactoring/removing CSS. Also removes auto-focus to search input when tab panel is mounted, since it's not a normal interaction for auto-focus with tabpanel implementation.
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
72cbfb3
to
bda3f20
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for the quick follow up!
Follow up to #60257
What?
Use
<Tabs />
component to render media categories in the inserter.Why?
The Pattern inserter now uses the
<Tabs />
component, so we should use the same interaction for the media inserter.How?
<Tabs />
usage into a<CategoryTabs />
component<CategoryTabs />
on both Pattern and Media inserterTesting Instructions
Testing Instructions for Keyboard
Screenshots or screencast