-
Notifications
You must be signed in to change notification settings - Fork 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
Add an optional prop to DocumentHead to set the raw window title #41803
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~6 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~159 bytes added 📈 [gzipped])
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 (~49 bytes added 📈 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
@@ -81,6 +81,7 @@ class DocumentHead extends Component { | |||
|
|||
DocumentHead.propTypes = { | |||
title: TranslatableString, | |||
formattedTitle: TranslatableString, |
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.
I think it may be worth adding this to the existing list of props within the documentation: https://github.com/Automattic/wp-calypso/blob/master/client/components/data/document-head/README.md
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.
Good catch, I missed that! Done in 5751f65
60cc3de
to
0ee2de6
Compare
5751f65
to
94ce4c2
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.
Thank you @DanReyLop for that refactoring! Changes look good and fine to be merged like this.
However, to be honest, having two competing title props slightly bothers me. What do you think on having a single title
prop and a flag, e.g. skipTitleFormatting
or titleIsFormatted
. This way IMO it's more explicit that title
is always a title and flag emphasizes desired behavior. What do you think?
@vbelolapotkov I implemented your suggestion in 383c41a I also rebased & force-pushed all the branches that are on top of this one, so |
…o intercept the "is this you? log in" link
… the default footer links.
…neric "from" parameter
…e without any extra formatting
…ing "title" props
383c41a
to
e49a4dd
Compare
0ee2de6
to
5025c40
Compare
Caution: This PR affects files in the FSE Plugin on WordPress.com D44535-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing in the FSE Plugin for more info: PCYsg-ly5-p2 |
<DocumentHead title={ translate( 'Jetpack Connect' ) } /> | ||
<DocumentHead | ||
title={ pageTitle || translate( 'Jetpack Connect' ) } | ||
skipTitleFormatting={ Boolean( pageTitle ) } |
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.
Just to verify: the fallback title, when pageTitle
prop is not supplied, is supposed to be formatted? E.g., Jetpack Connect --- WordPress.com (6)
?
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.
Yes, that's the existing behaviour.
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.
LGTM! Thank you @DanReyLop !
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.
Nice! I also like the skipTitleFormatting
API better than the original "raw title" one.
Changes proposed in this Pull Request
The
<DocumentHead>
component has atitle
prop, to set the tab title in the browser (document.title
). However, on top of whatever title is passed, it applies some extra formatting. For example, passingHello World
as a title can result in a window title beingHello World - WordPress.com (3)
.This PR adds a new optional prop,
formattedTitle
. If present, that string will be used as the raw window title, without any additions.It also adds an optional
pageTitle
prop to theJetpackConnectMainWrapper
component, that makes use of that prop.How to test
There's no code that calls
JetpackConnectMainWrapper
with apageTitle
prop, orDocumentHead
with aformattedTitle
prop, so there's no way to test this.Note: This is a required refactor for the new "Woo DNA" flow, implemented in #41798