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

DocumentHead: Update the title when it is different than the saved title #22501

Closed
wants to merge 1 commit into from

Conversation

ryelle
Copy link
Member

@ryelle ryelle commented Feb 15, 2018

In working on the WooCommerce extension on smaller screens, I noticed that sometimes the title would disappear from the page title & this section:

screen shot 2018-02-15 at 2 04 40 pm

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 in componentWillReceiveProps 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

  • View a section in Store where this happens: /store/orders/:site, or /store/reviews/:site are good cases
  • Check the page title, it should say Orders < Site Title – WordPress.com (or Reviews < …)
  • Change the filter on the page, click into "Awaiting Payment" (on Orders) or "Approved" (on Reviews)
  • Before this PR, the title would update to Site Title – WordPress.com
  • After this PR, the title should stay the same.
  • If you open the Redux inspector, you'll see the DOCUMENT_HEAD_TITLE_SET action fire.

@ryelle ryelle added Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 15, 2018
@ryelle ryelle self-assigned this Feb 15, 2018
@matticbot
Copy link
Contributor

@ryelle ryelle requested review from ockham and Tug February 15, 2018 19:25
@ryelle ryelle requested a review from a team March 12, 2018 20:38
@allendav
Copy link
Contributor

allendav commented Mar 12, 2018

I see something curious in my terminal when running this branch:

Ready! You can load http://calypso.localhost:3000/ now. Have fun!
HEAD /version?1520889453659 200 1158.203 ms - 20
HEAD /version?1520889473658 200 1156.606 ms - 20
HEAD /version?1520889493658 200 13.228 ms - 20
Warning: Each child in an array or iterator should have a unique "key" prop.

Check the top-level render call using <Head>. See https://fb.me/react-warning-keys for more information.
    in meta
    in Document
GET /store/allendavstoretest.blog 200 161.309 ms - 25118

I don't see that on master. Seems to happen after doing a force-refresh (Cmd-Shift-R) while looking at http://calypso.localhost:3000/store/YOURDOMAINHERE

@ryelle ryelle force-pushed the fix/document-title-update branch from ebf5171 to 4773074 Compare March 14, 2018 15:52
@ryelle
Copy link
Member Author

ryelle commented Mar 14, 2018

@allendav that was a problem on master at the time, it's been fixed & I rebased this branch, so you shouldn't see it now.

Copy link
Contributor

@justinshreve justinshreve left a comment

Choose a reason for hiding this comment

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

This is testing well for me and the changes look good.

@ryelle
Copy link
Member Author

ryelle commented Apr 11, 2018

This doesn't work on other calypso pages; the title is not updated when going between sections. Closing this for another approach, as this is still an issue on smaller screens

@ryelle ryelle closed this Apr 11, 2018
@ryelle ryelle deleted the fix/document-title-update branch April 11, 2018 20:45
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants