-
Notifications
You must be signed in to change notification settings - Fork 875
Search 3.0: hide the Off row of the feature-selector on WordPress.com (RSM-2400) #48558
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: changed | ||
|
|
||
| Search dashboard: hide the Off row of the new feature-selector on WordPress.com, matching the legacy module control's behaviour. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { useSelect, useDispatch } from '@wordpress/data'; | |
| import { __ } from '@wordpress/i18n'; | ||
| import { Button, Stack } from '@wordpress/ui'; | ||
| import { STORE_ID } from 'store'; | ||
| import { EXPERIENCE_ORDER } from './constants'; | ||
| import { EXPERIENCE, EXPERIENCE_ORDER } from './constants'; | ||
| import ExperienceOption from './experience-option'; | ||
| import './style.scss'; | ||
|
|
||
|
|
@@ -25,8 +25,16 @@ export default function FeatureSelector() { | |
| select => select( STORE_ID ).supportsOnlyClassicSearch(), | ||
| [] | ||
| ); | ||
| // On WordPress.com, search activation is managed from the .com side, so we | ||
| // hide the Off row here to mirror the legacy `<ModuleControl>`'s | ||
| // `! isWpcom` gate around the "Enable Jetpack Search" toggle. | ||
| const isWpcom = useSelect( select => select( STORE_ID ).isWpcom(), [] ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny style musing, totally take or leave: this brings the component to five |
||
| const { saveExperience } = useDispatch( STORE_ID ); | ||
|
|
||
| const visibleExperiences = isWpcom | ||
| ? EXPERIENCE_ORDER.filter( experience => experience !== EXPERIENCE.OFF ) | ||
| : EXPERIENCE_ORDER; | ||
|
|
||
| const isExperienceDisabled = experience => | ||
| supportsOnlyClassicSearch && ( experience === 'embedded' || experience === 'overlay' ); | ||
|
|
||
|
|
@@ -51,7 +59,7 @@ export default function FeatureSelector() { | |
| aria-labelledby="jp-search-feature-selector-heading" | ||
| > | ||
| <Stack direction="column" gap="sm"> | ||
| { EXPERIENCE_ORDER.map( experience => ( | ||
| { visibleExperiences.map( experience => ( | ||
| <ExperienceOption | ||
| key={ experience } | ||
| experience={ experience } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,4 +91,28 @@ describe( '<FeatureSelector>', () => { | |
| expect( screen.getByRole( 'radio', { name: /theme search/i } ) ).toBeEnabled(); | ||
| expect( screen.getByRole( 'radio', { name: /off/i } ) ).toBeEnabled(); | ||
| } ); | ||
|
|
||
| test( 'hides the Off row on WordPress.com (parity with legacy ModuleControl)', () => { | ||
| const registry = createRegistry(); | ||
| const store = createReduxStore( STORE_ID, { | ||
| ...storeConfig, | ||
| initialState: { | ||
| ...( storeConfig.initialState || {} ), | ||
| jetpackSettings: baseSettings, | ||
| siteData: { isWpcom: true }, | ||
| }, | ||
| } ); | ||
| registry.register( store ); | ||
| render( | ||
| <RegistryProvider value={ registry }> | ||
| <FeatureSelector /> | ||
| </RegistryProvider> | ||
| ); | ||
| const radios = screen.getAllByRole( 'radio' ); | ||
| expect( radios ).toHaveLength( 3 ); | ||
| expect( screen.getByRole( 'radio', { name: /embedded search/i } ) ).toBeInTheDocument(); | ||
| expect( screen.getByRole( 'radio', { name: /overlay search/i } ) ).toBeInTheDocument(); | ||
| expect( screen.getByRole( 'radio', { name: /theme search/i } ) ).toBeInTheDocument(); | ||
| expect( screen.queryByRole( 'radio', { name: /^off$/i } ) ).not.toBeInTheDocument(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One tiny thing on this assertion — the Off radio's accessible name is computed from the whole The good news: the |
||
| } ); | ||
| } ); | ||
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.
Small wording suggestion — and to be clear this isn't your invention, the same loose phrasing lives in the legacy
<ModuleControl>comment already. But while we're here:Helper::is_wpcom()only checks theIS_WPCOMconstant, which is defined on Simple sites and not on Atomic/WoA. So in practice an Atomic admin will still see the Off row here. That's actually correct behavior — the legacy<ModuleControl>gate has the same Simple-only meaning, so we're at parity — but a future reader scanning the comment might assume "WordPress.com" includes Atomic and get confused. Mind tightening to something like "On WordPress.com Simple sites" or "whereIS_WPCOMis defined"? Just so the Atomic case isn't ambiguous.