File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -476,11 +476,13 @@ function initJoinContact() {
476476 const selectedPrefix = status . dataset . selectedPrefix ?? 'Email subject:' ;
477477 const copiedPrefix = status . dataset . copiedPrefix ?? 'Copied email and subject:' ;
478478 const fallbackPrefix = status . dataset . copyFallbackPrefix ?? 'Use email and subject:' ;
479+ let selectionVersion = 0 ;
479480
480481 document . querySelectorAll < HTMLAnchorElement > ( '[data-join-contact-cta]' ) . forEach ( ( link ) => {
481482 if ( link . dataset . joinContactReady === 'true' ) return ;
482483 link . dataset . joinContactReady = 'true' ;
483484 link . addEventListener ( 'click' , ( ) => {
485+ const version = ++ selectionVersion ;
484486 const subject = link . dataset . contactSubject ?? '' ;
485487 const copyText = [ email , subject ? `Subject: ${ subject } ` : '' ] . filter ( Boolean ) . join ( '\n' ) ;
486488
@@ -497,11 +499,13 @@ function initJoinContact() {
497499 void navigator . clipboard
498500 . writeText ( copyText )
499501 . then ( ( ) => {
502+ if ( version !== selectionVersion ) return ;
500503 status . textContent = subject
501504 ? `${ copiedPrefix } ${ email } — ${ subject } `
502505 : `${ copiedPrefix } ${ email } ` ;
503506 } )
504507 . catch ( ( ) => {
508+ if ( version !== selectionVersion ) return ;
505509 status . textContent = subject
506510 ? `${ fallbackPrefix } ${ email } — ${ subject } `
507511 : `${ fallbackPrefix } ${ email } ` ;
You can’t perform that action at this time.
0 commit comments