fix image replacement via clipboard paste or drag and drop on PNG Info tab
diff --git a/javascript/dragdrop.js b/javascript/dragdrop.js
index 29e26766e88..c01f66e2dd5 100644
--- a/javascript/dragdrop.js
+++ b/javascript/dragdrop.js
@@ -10,22 +10,34 @@ function dropReplaceImage( imgWrap, files ) {
     }
 
     imgWrap.querySelector('.modify-upload button + button, .touch-none + div button + button')?.click();
-    window.requestAnimationFrame( () => {
+    const callback = () => {
         const fileInput = imgWrap.querySelector('input[type="file"]');
         if ( fileInput ) {
             fileInput.files = files;
             fileInput.dispatchEvent(new Event('change'));   
         }
-    });
-}
-
-function pressClearBtn(hoverElems) {
-    //Find all buttons hovering over the image box
-    let btns = Array.from(hoverElems.querySelectorAll("button"))
-
-    //Press the last btn which will be the X button
-    if (btns.length)
-        btns[btns.length-1].click()
+    };
+    
+    if ( imgWrap.closest('#pnginfo_image') ) {
+        // special treatment for PNG Info tab, wait for fetch request to finish
+        const oldFetch = window.fetch;
+        window.fetch = async (input, options) => {
+            const response = await oldFetch(input, options);
+            if ( 'api/predict/' === input ) {
+                const content = await response.text();
+                window.fetch = oldFetch;
+                window.requestAnimationFrame( () => callback() );
+                return new Response(content, {
+                    status: response.status,
+                    statusText: response.statusText,
+                    headers: response.headers
+                })
+            }
+            return response;
+        };        
+    } else {
+        window.requestAnimationFrame( () => callback() );
+    }
 }
 
 window.document.addEventListener('dragover', e => {
@@ -36,13 +48,7 @@ window.document.addEventListener('dragover', e => {
     }
     e.stopPropagation();
     e.preventDefault();
-
-    if (e.dataTransfer) 
-         e.dataTransfer.dropEffect = 'copy';   
-        
-    //If is gr.Interface clear image on hover
-    if (target.previousElementSibling)
-        pressClearBtn(target.previousElementSibling)
+    e.dataTransfer.dropEffect = 'copy';
 });
 
 window.document.addEventListener('drop', e => {
diff --git a/modules/ui.py b/modules/ui.py
index 0d428b5b330..e290b3ebb94 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -797,7 +797,7 @@ def apply_mode(mode, uploadmask):
     pnginfo_interface = gr.Interface(
         wrap_gradio_call(run_pnginfo),
         inputs=[
-            gr.Image(label="Source", source="upload", interactive=True, type="pil"),
+            gr.Image(elem_id="pnginfo_image", label="Source", source="upload", interactive=True, type="pil"),
         ],
         outputs=[
             gr.HTML(),

We have to wait for the ajax request after clearing the image before placing the new one

(also fixes #771)