File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/meshcore_hub/web/static/js/spa Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,9 @@ export function copyToClipboard(e, text) {
183183 e . preventDefault ( ) ;
184184 e . stopPropagation ( ) ;
185185
186+ // Capture target element synchronously before async operations
187+ const targetElement = e . currentTarget ;
188+
186189 const showSuccess = ( target ) => {
187190 const originalText = target . textContent ;
188191 target . textContent = 'Copied!' ;
@@ -196,14 +199,14 @@ export function copyToClipboard(e, text) {
196199 // Try modern Clipboard API first
197200 if ( navigator . clipboard && navigator . clipboard . writeText ) {
198201 navigator . clipboard . writeText ( text ) . then ( ( ) => {
199- showSuccess ( e . currentTarget ) ;
202+ showSuccess ( targetElement ) ;
200203 } ) . catch ( err => {
201204 console . error ( 'Clipboard API failed:' , err ) ;
202- fallbackCopy ( text , e . currentTarget ) ;
205+ fallbackCopy ( text , targetElement ) ;
203206 } ) ;
204207 } else {
205208 // Fallback for older browsers or non-secure contexts
206- fallbackCopy ( text , e . currentTarget ) ;
209+ fallbackCopy ( text , targetElement ) ;
207210 }
208211
209212 function fallbackCopy ( text , target ) {
You can’t perform that action at this time.
0 commit comments