Repository navigation
fix(signup): let useClipboardCopy own the Copy link timer - #1111
dafeiyupola wants to merge 2 commits into
Conversation
richshaw
left a comment
There was a problem hiding this comment.
Thanks for this.
Two things need fixing before this can go in:
- Formatting. CI fails
pnpm format:checkoncommit-dialog.tsxbecause the<p role="status" …>tag should fit on one line. Runningpnpm formatfixes it. CI stopped at that step, so the tests, build and size checks haven't run yet. - The German line in
KEEP_IT_PRIVATE. The PR deletesde: 'gib den Link nicht weiter',fromcommit-dialog.test.tsx. That line has nothing to do with this fix, and deleting it breaks the "say to keep the link private in de" test. The file comes out at 68 passed and 1 failed. Please put the line back.
One smaller fix that would be good to include:
- Closing the dialog no longer clears "Link copied".
handleCloseused to reset both copy states, but now the hook'scopiedstays true for up to 2 seconds. The dialog stays mounted after Done, so someone who reopens it and signs up again within those 2 seconds sees "Link copied" on the new panel. Adding areset()to the hook and calling it fromhandleClosewould fix this.
Optional:
- The new test waits on the real clock, which takes over 3 seconds. Fake timers would make it instant, and
useClipboardCopy.test.tsalready tests this with fake timers. - Nothing tests the "Save your link" fallback, where someone gave an email and the browser has no share sheet. A short test there would cover the new shared
linkCopiedlogic.
e45105d to
df30e23
Compare
|
Heads-up before this shows up as a red check: one test in I checked it both ways so it is not my change: the same assertion fails on a pristine checkout of Current state of this branch against |
df30e23 to
4e137f4
Compare
|
Thanks for the update. The German line is back, and the end-to-end tests pass. Two things from the review still need doing:
I checked the test you said already fails on |
What
The success panel keeps two hand-written copies of what
useClipboardCopyalready does:shareCopiedfor "Save your link" andcopyResultfor "Copy link", each with a baresetTimeout(…, 2000)and no timer id. Copy, then copy again 1.2 s later, and the first timer clears the label 0.8 s after the second copy instead of 2 s.Both are now the hook, as the issue outlines. Only one of the two buttons is on screen at a time, so one hook covers both.
handleCopyissetCopyFailed(!(await linkCopy.copy(success.editUrl))), the share fallback awaits the samecopy, and the status region reads fromcopyFailed/linkCopied.handleCloseresetscopyFailedonly — the hook'scopiedcan't be cleared from outside, and the panel is gone by then anyway.Test
One new case in
commit-dialog.test.tsx: copy, wait 1.2 s, copy again, then assert the label is still "Link copied" 1 s later — past the point where the first timer fired — and that it goes back to "Copy link" within 2 s of the second copy.Checked both directions:
Verification
I did not run the other 2,000-odd tests in the repo, only this file plus the type and lint checks — this touches one dialog's state, but saying "the suite passes" when I ran one file would be wrong.
Fixes #1087
Rebased twice while this sat;
mainmoved under it both times, which is fair for a repository this busy. The count above is from the current head (df30e23b), onmainas of7649fbc5.