Settings: Show empty state when search returns no matching settings#48102
Conversation
69c1bbd to
7a0393e
Compare
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryCoverage changed in 2 files.
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Aggregate selector that returns true when searchTerm is set and at least one module matches via isModuleFound. This will drive empty-state rendering on the settings screen.
Drive empty-state visibility from Redux state (via hasAnyMatchingModule) instead of the previous display: none + :last-of-type CSS hack, which did not reliably show or hide the message. Render the empty state as an h2 using the existing jp-settings__section-title treatment plus a new --centered BEM modifier, so it visually matches the main settings heading. Removes the obsolete .jp-no-results block.
Replace the ad-hoc h2 with the Gutenberg EmptyState compound component (icon + title + description) wrapped in a Stack for horizontal centering, matching the Jetpack settings treatment and the Gutenberg storybook default. Reset h2/p margins inside the wrapper because the component's built-in margin: 0 lives in @layer wp-ui-components and loses to unlayered admin styles.
Cover the four key cases: empty search term, unloaded modules state, at least one matching module, and no matching modules.
984f03a to
ff59f4e
Compare
|
@ilonagl would be nice to get your eyes on this too and see if the design implementation is okay here. |
| // take precedence and reintroduce h2/p margins. Reset them here so the | ||
| // component renders with its intended tight spacing. | ||
| h2, | ||
| p { | ||
| margin: 0; | ||
| } |
There was a problem hiding this comment.
This is fixed in the next @wordpress/ui version with WordPress/gutenberg#76970
I pinged renovate to open a new PR to update bundled WP deps. Once that's merged, these lines can be removed.
simison
left a comment
There was a problem hiding this comment.
Haven't tested but code looks good!
|
Thank you for the ping, @nerrad! It looks good. I'd tweak the copy a bit to make it more actionable/visible: Header: "No settings found for “adave”" Also, is there a way to make the empty size height flexible, so the footer stays at the bottom of the screen vs moving in the middle?
Nice to have: I'd also put actions directly in the empty state: "Clear search" as secondary, and "Browse all settings" that closes the search and opens the first tab from in settings. |
|
Making the footer sticky at the bottom of the viewport is solved in this PR: |
|
I'll deploy this as-is now to get |

Proposed changes
Typing into the Settings search bar could leave a completely blank screen when the term matched no settings — no message, no feedback. This PR surfaces a proper empty state so users get clear guidance instead of a blank canvas.
.jp-no-resultsdiv was always rendered and its visibility was governed by adisplay: none+:last-of-typeCSS trick that is fragile (:last-of-typeis tag-based, not class-based) and in practice left the settings area blank.hasAnyMatchingModuleselector instate/search, reusing the existingisModuleFound+getModulesselectors.EmptyStatecompound component from@wordpress/ui(search icon + title + description), wrapped in aStackfor horizontal centering.@wordpress/ui@0.10.0toplugins/jetpack— one minor ahead of the0.9.0used elsewhere in the monorepo, becauseEmptyStatewas first exported in 0.10.0..jp-no-resultsCSS block.Does this pull request change what data or activity we track or use?
No.
Testing instructions
asdfqwerty.backup,sharing). Verify the matching sections render and the empty state does not.