@@ -208,6 +208,24 @@ class ErrorBoundary extends React.Component {
208208 setTimeout ( ( ) => window . location . reload ( ) , 300 ) ;
209209 } ;
210210
211+ handleCopyReport = async ( ) => {
212+ const { error, errorInfo, errorId } = this . state ;
213+ const report = buildDiagnosticReport ( errorId , error , errorInfo ) ;
214+
215+ try {
216+ await navigator . clipboard . writeText ( report ) ;
217+ this . setState ( { copied : true } ) ;
218+ setTimeout ( ( ) => this . setState ( { copied : false } ) , 2000 ) ;
219+ } catch ( err ) {
220+ console . error ( "Clipboard copy failed, using fallback:" , err ) ;
221+ try {
222+ const blob = new Blob ( [ report ] , { type : "text/plain" } ) ;
223+ const url = URL . createObjectURL ( blob ) ;
224+ window . open ( url , "_blank" , "noopener,noreferrer" ) ;
225+ } catch ( _ ) { }
226+ }
227+ } ;
228+
211229 handleTryAgain = ( ) => {
212230 const { retryCount } = this . state ;
213231 if ( retryCount >= 3 ) {
@@ -252,25 +270,6 @@ class ErrorBoundary extends React.Component {
252270 setTimeout ( ( ) => window . location . reload ( ) , 300 ) ;
253271 } ;
254272
255- handleCopyReport = ( ) => {
256- const { error, errorInfo, errorId } = this . state ;
257- const report = buildDiagnosticReport ( errorId , error , errorInfo ) ;
258-
259- navigator . clipboard
260- . writeText ( report )
261- . then ( ( ) => {
262- this . setState ( { copied : true } ) ;
263- setTimeout ( ( ) => this . setState ( { copied : false } ) , 2000 ) ;
264- } )
265- . catch ( ( ) => {
266- try {
267- const blob = new Blob ( [ report ] , { type : "text/plain" } ) ;
268- const url = URL . createObjectURL ( blob ) ;
269- window . open ( url , "_blank" , "noopener,noreferrer" ) ;
270- } catch { }
271- } ) ;
272- } ;
273-
274273 toggleDiagnostics = ( ) => {
275274 this . setState ( ( prev ) => ( { showDiagnostics : ! prev . showDiagnostics } ) ) ;
276275 } ;
0 commit comments