Repository navigation
fix(auth): render the Google sign-in button at the form's width - #746
RounakKumarAgarwal wants to merge 2 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Also attach a proof of your test pass of all the test present. |
|
Read through the diff, the clamp to 200..400 makes sense since GIS ignores percentages. One thing: googleButtonWidth runs only when the button first renders, so if the form width changes later (resize, rotating a phone) the button keeps the old size. Might be worth re-rendering it from a ResizeObserver on the container. Small nit, clientWidth is already an integer so the Math.round can go. |
|
@Ri1tik I've added the test passing screenshot in pr description , please check it out |
renderButton was given width: '100%', but Google Identity Services only accepts a pixel width (200-400), so it ignored the value and shrank the button to fit its text. Measure the container, clamp to Google's range, and centre the button. Applies to both the sign-in and sign-up forms.
…e script Move the Google button setup into a shared useGoogleButton hook used by both the login and sign-up forms: - Redraw the button at the container's new width when it changes (ResizeObserver, debounced 100 ms), so it keeps matching the form after a window resize or phone rotation. - If the Google script hasn't loaded yet when the form mounts, poll for it every 100 ms and give up with a console warning after 10 s. - Initialize Google once per mount; skip redraws when the width is unchanged. The resize and script-wait approach is adapted from AOSSIE-Org#774 by @aryanpatil-07.
951260b to
88f87f8
Compare
Problem
The "Sign in with Google" button on
/authwas rendered shrunk to the size of its text instead of matching the form's width.Fix
Google's
renderButtonignores'100%'and only accepts a pixel width between 200 and 400px. The button setup now lives in a shared hook,useGoogleButton, which measures the form's width and passes it in pixels:useEffectblocksrenderButton's type is changed towidth?: number, so a percentage can't be passed againTesting
googleLogin, and cleanupnpm run buildsucceedsScreenshots
Before (live):

After:

Screen.Recording.2026-10-22.211258.mp4