DocumentHead: Update the title when it is different than the saved title #22501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In working on the WooCommerce extension on smaller screens, I noticed that sometimes the title would disappear from the page title & this section:
Note, this section isn't currently visible in Store, to test you'll need to watch the title itself.
I tracked this to
documentHead.title
in redux state, which is cleared when the route is changed. In other sections of calypso, this is set either by directly calling an action, or using<DocumentHead>
. In WC, we use the<DocumentHead>
approach in our parent component, so this doesn't unmount/remount like some other sections of Calypso (settings, for example). This means if the document title doesn't change from section-to-section, the logic incomponentWillReceiveProps
considers it "unchanged" and won't fire the action to update it (even though it's actually an empty string).This PR updates
DocumentHead
to check against the title currently saved in redux.To test
/store/orders/:site
, or/store/reviews/:site
are good casesOrders < Site Title – WordPress.com
(or Reviews < …)Site Title – WordPress.com
DOCUMENT_HEAD_TITLE_SET
action fire.