-
Notifications
You must be signed in to change notification settings - Fork 75
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
Fix Google Login button disappearing issue #3197
base: master
Are you sure you want to change the base?
Conversation
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 would be better to set up a Promise
to guarantee that the window.onGoogleLibraryLoad
function is defined before the Google script attempts to call it. In the current implementation, having two separate window.onGoogleLibraryLoad
function calls within the same file feels inconsistent.
I made some mistakes in my previous description. Currently, the Google script is loaded statically, meaning it is automatically loaded via the To address this timing issue, I decided to stop relying on the |
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.
Looks better than the previous version. Please add a comment that timeout is in milliseconds and also add a unit test for the following scenario:
"should initialize Google login button when script is loaded"
@aglinxinyuan Adding you to be a second reviewer for this PR since you are familiar with the Google Login feature. |
The code itself seems fine to me, but maintaining such a simple function might require significant effort on our end. For instance, we would need to monitor any API changes from Google's side and ensure it's always up to date. It might be worth considering using a third-party library instead. |
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!
{ | ||
id: GoogleLoginProvider.PROVIDER_ID, | ||
provider: new GoogleLoginProvider(response?.clientId || "", { | ||
oneTapEnabled: 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.
Is there any reason to disable oneTap?
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.
Purpose:
The current Google login button occasionally disappears. The reason is that the Google script is loaded statically, meaning it is automatically loaded via the
<script>
tag when the page loads. This approach has a potential issue: if we want to use theonGoogleLibraryLoad
callback function to confirm that the script has successfully loaded, we must ensure that the callback is defined before the script finishes loading. Otherwise, when the script completes loading, Google will check whetheronGoogleLibraryLoad
is defined. If it is not defined, the script load notification will be missed, and the Google login initialization logic will not execute.fix #3155
Changes:
yarn install
to install it.Demos:
Before:
before.mp4
After:
after.mp4