-
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
Social Signup: Handle the case where users block third-party cookies/data #13983
Conversation
I just hacked in some CSS for the error message, I would appreciate a pointer as to what CSS rules I should actually be using. :-) |
@@ -19,6 +19,8 @@ class GoogleLoginButton extends Component { | |||
fetchBasicProfile: true, | |||
}; | |||
|
|||
state = { error: false }; |
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.
It should be initialised to either null
or an empty string ``.
@@ -45,6 +47,10 @@ class GoogleLoginButton extends Component { | |||
return this.initialized; | |||
} | |||
|
|||
this.setState( { error: '' } ); |
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.
Can it be initialized more than once? If not then we can remove this state change.
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.
Yep, initialize()
can be called multiple times - this.initialized
won't be set until the gapi
instance is properly initialised.
@@ -73,26 +91,33 @@ class GoogleLoginButton extends Component { | |||
} | |||
|
|||
render() { | |||
let buttonDisabled = false; |
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.
It can be simplified to:
const buttonDisabled = Boolean( this.state.error );
this.setState( { error: translate( 'Your privacy settings are blocking us from connecting to your Google account. ' + | ||
'Please enable "third-party cookies" in your browser or operating system, or log in with an email address instead.' | ||
) } ); | ||
return null; |
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.
@Tug should we return rejected Promise in this case, too?
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, I believe we can simply remove that return statement.
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.
If i removed the return null
, the console shows a JS error:
Object {error: "idpiframe_initialization_failed", details: "Failed to read the 'localStorage' property from 'Window': Access is denied for this document."}
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's fine to show an error in the console here. if we want to hide it in a debug()
call for instance, that should be done by calling catch
on the promise returned by this.initialize()
.
I guess it needs some tweaks :) I left my comments, those are only nitpicks. It works as advertised. Let's hear from designers before we merge this one. |
I wonder if we could be more proactive about this, and display the error message without a click? It's not a big issue if it's going to mean a lot more work, but it'd be nicer to disable the social buttons from start if they can't be used. Also, since we're on signup, the copy should probably say "or sign up with an email address" instead of "or log in with an email address". cc @breezyskies for design input. I'm not sure I've seen errors associated with buttons displayed like we're doing in this PR. I suppose we usually go with a notice in cases like this? |
Updated this with 61efbdd. |
Correct, this would need to be a notice. Given the length of the copy, I don't think we can use global notices in this case, so would need to be the standard notice component. |
It's already the case, the lib is loaded when the component mounts. I tested it and it seems to work. |
Yes, there is no need to click anything. |
The downside of that is we're showing an error message to someone who might not even choose to use social signup. |
Hm... Weird, I must have missed something while testing 🤔 Anyway, now that we're talking about using a notice, I have the same concern as Brie. The notice is quite prominent with its size and color, and might distract users from their actual goals (or just generally cause confusion since third-party cookies are not familiar to all users). Maybe the best would be to indeed only display the error on click. |
What do you think about disable state with tooltip? We could add a small red icon indicating some error inside the button. |
@@ -50,3 +50,9 @@ | |||
.signup-form__notice.notice { | |||
margin-bottom: 10px; | |||
} | |||
|
|||
.social-buttons__service-error { | |||
color: red; |
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.
Color can only use one of our color variables, in this case $alert-red
.social-buttons__service-error { | ||
color: red; | ||
font-size: 11px; | ||
margin: 0 10px 10px 10px; |
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.
Can be shortened to margin: 0 10px 10px;
I believe
A lot of this text is superfluous. But, focusing on just the error text:
I would clean up all of the text I pointed to in the screenshot by doing this:
cc @ranh for the shortened error text I wrote |
Nice improvement on that cookies notice @drw158, 👍 Your suggestion also removes "Connect to your existing social profile to get started faster". This sentence is meant to provide additional context for users who will not immediately understand the function or benefit of the "social" buttons. I don't think it's superfluous, so I think we should keep it. |
{ this.props.translate( | ||
"Connect to your existing social profile to get started faster. We'll never post without your permission." | ||
) } | ||
{ this.props.translate( 'Connect to your existing social profile to get started faster.' ) } |
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.
😞 17 existing translations will be lost with this change.
The popover will only show when the button is hovered or clicked.
fd5e5cf
to
8084b81
Compare
LGTM. 👍 |
Actually, we need to fix the tests first. :) I rebased and they are failing due to the import of |
That this can even happen is... less than optimal. 🙃 |
render() { | ||
let classes = 'social-buttons__button button'; |
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.
Another option is:
import classNames from 'classnames';
classNames( 'social-buttons__button', 'button', { disabled: this.state.error } );
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.
So many magic functions. 😁
Code looks 👍 It works for me in Chrome when I disable "third party cookies" 👍 All tests pass 👍 |
This pull request addresses #13553 by disabling the Google signup button, and showing an error message, when 3rd party cookies are disabled:
Testing instructions
git checkout fix/13553-signup-3rd-party-cookies
and start your server, or open a live branchSocial Signup
pageReviews