wp-calypso
wp-calypso copied to clipboard
Launch flow: Populate search results
Proposed Changes
Fixes a bug in which under certain conditions, the launch site flow could open with no pre-populated search results. So, users are forced to type out a domain to proceed with launching a site. This issue is further described in https://github.com/Automattic/wp-calypso/issues/63050.
When does this happen?
Under the following conditions, the launch flow can render the domain step with no search results on initial render:
- While signing up for a new account, click "Choose Domain Later" in the domain step.
- Launch site from Settings > General.
Another scenario which could cause this error:
- Signup for a new account.
- Launch site from Settings > General in a different device or browser, or from an incognito window.
Why does this happen?
The launch flow uses the last domain searched value to pre-populate the search results:
https://github.com/Automattic/wp-calypso/blob/665fb5ebace3d26cfcb988f9c3d7eccdd7909efb/client/components/domains/register-domain-step/index.jsx#L170-L176
The last search value could be empty under the following conditions:
- User never searched for a domain, they skipped the domain step in signup, and hence this value is empty.
- The last searched value is stored in local storage and this value could be unreadable if a different device or browser is used, or if an incognito window was used.
What's the proposed fix?
To use the last searched value if it exists, otherwise pre-populate results from the site's subdomain name. WordPress.com subdomain's sometimes have random numbers appended to them, as part of the logic by which these are generated, so it would be nice to remove these random numbers when pre-populating the search results. We already do this in the domain search page in Calypso.
Launching From My Home
As mentioned above, this issue is seen only when launching from the Settings page. The My Home page doesn't produce this bug, but I'm not convinced with the domain search term it uses to pre-populate the results. The domain search term when launching from My Home is not stripped off the random numbers I mentioned previously, and it doesn't read the last searched term if it exists. It defaults to using the subdomain as the search term, and there are many situations in which the subdomain is generated randomly. It would be a better experience to use the last searched term if it exists, since that directly aligns with the user's keyword interests. This PR doesn't modify the logic in My Home yet, but if it's agreeable, I'll make that change too.
Testing Instructions
- Signup for a new site and in the domains step of signup flow, click "Choose domain later".
- In Settings > General, click on Launch Site and verify that the domain page is pre-populated with the subdomain as the search keyword.
- If the subdomain has several numbers, like mydomain32432423 .wordpress.com, then verify that the domain search term strips away these numbers, so the search keyword is simply "mydomain" as per the example I shared.
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:
Sections (~90 bytes added 📈 [gzipped])
name parsed_size gzip_size
domains +307 B (+0.0%) +90 B (+0.0%)
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.
Async-loaded Components (~104 bytes added 📈 [gzipped])
name parsed_size gzip_size
async-load-signup-steps-domains +358 B (+0.1%) +104 B (+0.1%)
React components that are loaded lazily, when a certain part of UI is displayed for the first time.
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.
Since this is now centralized into the flow, should we remove the URL queries from my home and header added previously?
Since this is now centralized into the flow, should we remove the URL queries from my home and header added previously?
Will take care of reverting those.
@yansern @daledupreez Could you please give it a scan again if the updated regex looks good to you?
Also, note that one behaviour difference is that the subdomain will be shown on the input field, where the previous behaviour does not show it via the hide_initial_query param.
@niranjan-uma-shankar this would be cool to fix either in this PR or in a follow up.
I'll fix it in a follow-up, thanks.
UPDATE: Fix is in https://github.com/Automattic/wp-calypso/pull/68254. cc @yansern @simison