-
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
Boot: Don't render empty Layout #26944
Conversation
errorLogger.saveDiagnosticReducer( () => ( { tests: getSavedVariations() } ) ); | ||
analytics.on( 'record-event', ( eventName, eventProperties ) => | ||
errorLogger.saveExtraData( { lastTracksEvent: eventProperties } ) | ||
if ( config.isEnabled( 'catch-js-errors' ) && ! document.getElementById( 'primary' ) ) { |
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've retained the ! document.getElementById( 'primary' )
criterion here, since the catch-js-errors
stuff was originally wrapped in it, but I have a hunch that it's not really required for it.
Of note, document.getElementById( 'primary' )
isn't always false
-- isomorphic sections (such as /themes
) render a component hierarchy on the server side, so the client will find a #primary
div
. (However, the rationale found in the PR desc still holds -- all individual sections render their own Layout
component hierarchy, so we don't need to render an empty Layout
here.)
The e2e tests don't like this branch - I am trying to work out why. One thing that stands out is the notifications panel doesn't work:
|
Thanks @alisterscott, looking into this now... |
The 'Write Post' button has a similar issue, where rather than just opening the sites dropdown, it takes the user right away to the post editor. |
Weird. Removing that empty |
I stumbled upon the same issue even without this patch applied, when working on Webpack CSS for the What's going on here? The clicked element is a link that has both <a href="/notifications" onClick={ toggleNotesFrame } /> The theory is that In practice, there are two complications:
As the event first goes through There is a second complication that pierces both defenses 😄 In React, So, in DOM, we have two If the React one was registered first and This patch changes the order of these listeners, as it removes the To verify, place breakpoints inside The bug can happen even without this patch applied, when two conditions hold:
|
Great sleuthing, thanks a lot, Jarda! The |
Makes me wonder about potential fixes:
Edit: Neither works 🙁 |
Notifications and subscribe button work with this patch diff --git a/client/boot/app.js b/client/boot/app.js
index 5db2d2c..a98ee6b 100644
--- a/client/boot/app.js
+++ b/client/boot/app.js
@@ -33,7 +33,7 @@ const boot = currentUser => {
setupMiddlewares( currentUser, reduxStore );
invoke( project, 'setupMiddlewares', currentUser, reduxStore );
detectHistoryNavigation.start();
- page.start( { decodeURLComponents: false } );
+ page.start( { click: false, decodeURLComponents: false } );
} );
};
But that would mean losing client-side routing, which we obviously don't want to lose! |
I think that The
Additionally, React 17 plans to become grumpy when the SSR content doesn't exactly match the client-rendered content when hydrating. (link)
Yes, I think that removing the global |
Yeah, makes sense. I kinda expected something like that, but I found
Yeah, I'm fully aware that we can't just drop client side handling and call it a day 😅
Yep, that's going to be "fun". I mean there might be other ways, like setting up Well, #26930 is just in exploratory state right now, and even if we decide to move forward with it, I can pass a |
Yes, that's going to work and seems to be the easiest way to unblock this. Init page.js with <div className="layout" onClick={ stealAhrefClicks }> The handler will be the same. Unfortunately page.js doesn't export it, so we'll need to copy&paste it. As the click hander is now part of the React event system, bubbling from target up the element hierarchy will work as expected. Do we use The best long term solution is still a react-router-like |
There are at least |
It sounds like we should also update the notifications HTML - it's not an |
We'll need to watch out for react-dom changes that are coming too. See facebook/react#2043 and facebook/react#13525 |
Aside, love it when a 'cleanup'/'janitorial' PR reveals that we're relying on an oversight for things to work 🙄 https://xkcd.com/1172/ |
Thanks Ben. In facebook/react#13525, they're framing facebook/react#2043 to be specifically about |
I've released that as page.js 1.11.1: https://github.com/visionmedia/page.js/releases/tag/1.11.1 . Thanks a lot for your patience with me and for the contribution. |
I tested this on https://calypso.live/?branch=remove/boot-empty-layout and also locally and the whole page view flashes blank on every load - so for example the sidebar flashes on every click - this is most obvious when you use mobile sized views. This is the reason the e2e tests are failing also. |
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.
Issues with rendering and flashing on testing
669efdd
to
7d23fc0
Compare
That's because this PR relies on page.js being upgraded to 1.11.1. I pushed a commit that does the upgrade. Let's check if things are fixed now. |
The e2e tests are failing because a masterbar doesn't load on the logged out base version of this URL: https://hash-7d23fc0077b078359949da3bc93c7a814783cf78.calypso.live/?apppromo Compared to other branches which show the masterbar: https://hash-80ba41927f2074836f28d5bc414086d685013b6d.calypso.live/?apppromo |
Yes, apparently there is no page.js handler that would handle the logged out version of |
Makes e2e tests happy, should eventually be replaced with some more systematic approach to how to handle logged-out pages and redirects to login page.
7d23fc0
to
e5b64d2
Compare
Pushed a simple fix in e5b64d2. Eventually such logged-out routes should redirect to login page. Folks have been doing that for selected individual pages that are target of links from emails (campaings, notifications): Anyway, let's see if the tests are more happy now 🤞 |
All tests are 💚 now -- ready for final 👀 and 🚢ping |
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.
Tests well and all e2e tests passing 👍
I had to revert this because SSR of the login page breaks: See also p1541402019129800-slack-calypso Apprarently React is very sensitive when it hydrates a server-rendered markup on the client and the markup on both sides is not exactly the same. This PR introduced some subtle change that breaks the hydration. To be debugged. |
😬 Is that every log in page? I'm guessing the page is still functional just horribly rendered considering all our e2e tests passed and they use that page |
@alisterscott I didn't debug this issue yet, so I don't know why it's happening. The rendered page is good enough for e2e tests to pass. The form fields and buttons are there and are active. But the HTML markup is corrupted and the rendering and styling is broken. I suspect that the |
This is a left-over that we must've missed when enabling single-tree rendering.
All of Calypso's client-side
page()
route definitions now includemakeLayout
andrender
middleware, so rendering an emptyLayout
component during bootstrapping is obsolete.Discovered while working on, and needed for #26930.
Best viewed without whitespace changes.
To test: