Skip to content
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

Jetpack Search: instant search toggle should change with Jetpack Search toggle #52631

Merged
merged 16 commits into from
May 13, 2021

Conversation

kangzj
Copy link
Contributor

@kangzj kangzj commented May 6, 2021

Fixes: #52404

Changes proposed in this Pull Request

  • When disabling Jetpack Search, instant search would also be disabled which is a child option under Jetpack Search, which also aligns with Jetpack plugin settings page.
  • And, because we recommend instant search, when Jetpack is re-enabled, instant search would be re-enabled too.
  • Changed label to be clearer - 'Enable Jetpack Search'
  • Separate the setting saving of jetpack sites (including Atomic) from simple sites to avoid a random error discussed in P2.

Discussion

pcNPJE-8a-p2

Testing instructions

  • Open Settings->General->Performance of a site with Jetpack Search plan (Atomic/Simple/Jetpack sites) in Clypso
  • Ensure when Jetpack Search is toggled disabled, instant search is disabled as well.
  • Ensure when Jetpack Search is toggled enabled, instant search is set to enabled.
  • Ensure Instant search toggle could change and save without affecting Jetpack Search toggle.
  • Ensure it works for Atomic / Simple / Jetpack site.

image

Gif: https://d.pr/i/dl2HRh

@kangzj kangzj added [Feature] Site Settings All other general site settings. [Status] In Progress [Feature] Search Jetpack Search - A feature to speed up and improve the look of Search on your site. labels May 6, 2021
@kangzj kangzj self-assigned this May 6, 2021
@github-actions
Copy link

github-actions bot commented May 6, 2021

@matticbot
Copy link
Contributor

matticbot commented May 6, 2021

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~317 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
settings-performance      +1342 B  (+0.3%)     +248 B  (+0.2%)
settings-writing           +506 B  (+0.1%)     +115 B  (+0.1%)
settings-security          +506 B  (+0.2%)     +117 B  (+0.1%)
settings-discussion        +506 B  (+0.2%)     +117 B  (+0.1%)
marketing                  +506 B  (+0.1%)     +116 B  (+0.1%)
settings                   +443 B  (+0.1%)      +99 B  (+0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@kangzj kangzj changed the title Jetpack Search: instant search toggle should change when Jetapck Search toggle changes Jetpack Search: instant search toggle should change with Jetapck Search toggle May 6, 2021
@kangzj
Copy link
Contributor Author

kangzj commented May 6, 2021

When updating instant search toggle (live or on this branch), it calls /rest/v1.1/jetpack-blogs/190071516/rest-api/?http_envelope=1 to sync the Jetpack setting to the site, which sometimes fails with error code 400.

The above issue mentioned will be looked at separately.

Request

{"path":"/jetpack/v4/settings/","body":"{\"lazy-images\":true,\"photon-cdn\":false,\"photon\":false,\"instant_search_enabled\":true}","json":true}
```

Response
```JSON
{"code":400,"headers":[{"name":"Content-Type","value":"application\/json"}],"body":{"error":"some_updated","message":""}}

@bluefuton bluefuton changed the title Jetpack Search: instant search toggle should change with Jetapck Search toggle Jetpack Search: instant search toggle should change with Jetpack Search toggle May 6, 2021
@kangzj kangzj added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels May 11, 2021
@kangzj kangzj requested a review from bluefuton May 11, 2021 02:05
@bluefuton bluefuton requested a review from jsnmoon May 11, 2021 02:10
@bluefuton
Copy link
Contributor

I notice that sometimes the instant search toggle loads before the main JP Search toggle - could we do checked={ fields.jetpack_search_enabled && fields.jetpack_instant_search_enabled } for that second toggle?

@bluefuton
Copy link
Contributor

The "If deactivated..." part of the description seems a bit redundant now we've made the main toggle label clearer ('Enable Jetpack Search'). Might also be confusing in light of the 'submit' overlay trigger we're adding in Automattic/jetpack#19795. Shall we drop it?

@kangzj
Copy link
Contributor Author

kangzj commented May 11, 2021

The "If deactivated..." part of the description seems a bit redundant now we've made the main toggle label clearer ('Enable Jetpack Search'). Might also be confusing in light of the 'submit' overlay trigger we're adding in Automattic/jetpack#19795. Shall we drop it?

Agree. The text is a bit vague now, removed in 96a8bef.

@kangzj
Copy link
Contributor Author

kangzj commented May 12, 2021

I notice that sometimes the instant search toggle loads before the main JP Search toggle - could we do checked={ fields.jetpack_search_enabled && fields.jetpack_instant_search_enabled } for that second toggle?

Good point. Fixed in 5b6d040

Copy link
Member

@jsnmoon jsnmoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good overall. Two questions:

  1. Would it be possible to keep the Instant Search enabled even if the Search module is disabled? (e.g. When Instant Search is enabled, the Search module is also toggled on.) This is how it currently works in /wp-admin/admin.php?page=jetpack#/performance.

  2. What do we gain by refactoring renderSettingsCard to create renderSearchTogglesForJetpackSites and renderSearchTogglesForSimpleSites? I'm seeing a bit of duplicated code (e.g. form toggles' disabled conditional) and am curious about the rationale for this change. Is it to improve code clarity?

EDIT: Meant to say "keep the Instant Search toggle enabled" for point 1.

@kangzj kangzj force-pushed the fix/instant-search-toggle branch from e156589 to 4b5c06c Compare May 13, 2021 00:17
@kangzj
Copy link
Contributor Author

kangzj commented May 13, 2021

Thanks for your review @jsnmoon :-)

  1. Would it be possible to keep the Instant Search enabled even if the Search module is disabled? (e.g. When Instant Search is enabled, the Search module is also toggled on.) This is how it currently works in /wp-admin/admin.php?page=jetpack#/performance.

Hmmm, are you sure? As I tested, the way proposed in the PR works the same as it is in WP Admin - the Instant Search option toggles with the Search option. And actually this is one of the reasons to change in Calypso - to align experience.

  1. What do we gain by refactoring renderSettingsCard to create renderSearchTogglesForJetpackSites and renderSearchTogglesForSimpleSites? I'm seeing a bit of duplicated code (e.g. form toggles' disabled conditional) and am curious about the rationale for this change. Is it to improve code clarity?

Yes it is, otherwise we'll have to test whether the site is Jetpack or not for every component (and attributes), which is not very pleasant to read. By refactoring it like above, there is a bit of duplication, but much better readability.

@kangzj kangzj force-pushed the fix/instant-search-toggle branch from 4b5c06c to 28626a4 Compare May 13, 2021 00:25
@kangzj kangzj requested a review from bluefuton May 13, 2021 01:10
this.props.saveInstantSearchRequest?.lastUpdated ) &&
this.props.siteId === prevProps.siteId
) {
// NOTE: 1. the condition is pretty messy - the problem is that, if a request is the same
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust your research here :) Works as intended!

Copy link
Contributor

@bluefuton bluefuton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚢

@bluefuton bluefuton added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 13, 2021
@kangzj kangzj merged commit 85d0a76 into trunk May 13, 2021
@kangzj kangzj deleted the fix/instant-search-toggle branch May 13, 2021 03:57
@kangzj
Copy link
Contributor Author

kangzj commented May 13, 2021

Looks good! 🚢

Thanks @bluefuton

So excited to get this done!!

@a8ci18n
Copy link

a8ci18n commented May 13, 2021

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/5902969

Thank you @kangzj for including a screenshot in the description! This is really helpful for our translators.

@jsnmoon
Copy link
Member

jsnmoon commented May 13, 2021

  1. Would it be possible to keep the Instant Search enabled even if the Search module is disabled? (e.g. When Instant Search is enabled, the Search module is also toggled on.) This is how it currently works in /wp-admin/admin.php?page=jetpack#/performance.

Hmmm, are you sure? As I tested, the way proposed in the PR works the same as it is in WP Admin - the Instant Search option toggles with the Search option. And actually this is one of the reasons to change in Calypso - to align experience.

Oops, I fat-fingered my initial review. I meant to say if it would be possible to keep the Instant Search toggle enabled even if the search module is disabled. This is how it currently works in wp-admin:

Video.MP4.1070x336.mp4

Since the Instant Search toggle is disabled when the module is disabled, this UX is not currently possible:

Screen Shot 2021-05-13 at 1 36 20 PM

@kangzj
Copy link
Contributor Author

kangzj commented May 13, 2021

I meant to say if it would be possible to keep the Instant Search toggle enabled even if the search module is disabled.

Ha got it. It makes sense. Thanks for reporting this, will get it addressed with #52736

@cavalierlife
Copy link

@kangzj I think the new wording looks good. Approved from our end.

@kangzj
Copy link
Contributor Author

kangzj commented May 18, 2021

Thanks @cavalierlife 👍

@a8ci18n
Copy link

a8ci18n commented May 21, 2021

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search Jetpack Search - A feature to speed up and improve the look of Search on your site. [Feature] Site Settings All other general site settings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Settings: if Jetpack Search is turned off, Instant Search should appear untoggled too
6 participants