Spaces:
Running on Zero
Running on Zero
Commit ·
c71e56e
1
Parent(s): ff59c3d
fix: use window.top.document for toast and max z-index
Browse filesGradio js= callbacks may run in a context where document.body is not
the visible page body. Use window.top.document to guarantee the toast
lands on the real page, and set z-index to INT_MAX so it clears all
Gradio overlays.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -2130,14 +2130,18 @@ _GLOBAL_JS = """
|
|
| 2130 |
|
| 2131 |
// Toast notification — styled like ZeroGPU quota warnings.
|
| 2132 |
function _showRegenToast(message, isError) {
|
| 2133 |
-
|
|
|
|
|
|
|
|
|
|
| 2134 |
t.style.cssText = 'position:fixed;bottom:24px;left:50%;transform:translateX(-50%);' +
|
| 2135 |
-
'z-index:
|
| 2136 |
-
'font-size:13px;max-width:
|
| 2137 |
'background:' + (isError ? '#7a1c1c' : '#1c4a1c') + ';color:#fff;' +
|
| 2138 |
-
'border:1px solid ' + (isError ? '#c0392b' : '#27ae60') + ';'
|
|
|
|
| 2139 |
t.textContent = message;
|
| 2140 |
-
|
| 2141 |
setTimeout(function() {
|
| 2142 |
t.style.transition = 'opacity 0.5s';
|
| 2143 |
t.style.opacity = '0';
|
|
|
|
| 2130 |
|
| 2131 |
// Toast notification — styled like ZeroGPU quota warnings.
|
| 2132 |
function _showRegenToast(message, isError) {
|
| 2133 |
+
// Use window.top.document so the toast always lands on the visible page,
|
| 2134 |
+
// regardless of whether this JS runs inside a Gradio shadow context.
|
| 2135 |
+
var doc = (window.top && window.top.document) ? window.top.document : document;
|
| 2136 |
+
var t = doc.createElement('div');
|
| 2137 |
t.style.cssText = 'position:fixed;bottom:24px;left:50%;transform:translateX(-50%);' +
|
| 2138 |
+
'z-index:2147483647;padding:12px 20px;border-radius:8px;font-family:sans-serif;' +
|
| 2139 |
+
'font-size:13px;max-width:520px;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,.6);' +
|
| 2140 |
'background:' + (isError ? '#7a1c1c' : '#1c4a1c') + ';color:#fff;' +
|
| 2141 |
+
'border:1px solid ' + (isError ? '#c0392b' : '#27ae60') + ';' +
|
| 2142 |
+
'pointer-events:none;';
|
| 2143 |
t.textContent = message;
|
| 2144 |
+
doc.body.appendChild(t);
|
| 2145 |
setTimeout(function() {
|
| 2146 |
t.style.transition = 'opacity 0.5s';
|
| 2147 |
t.style.opacity = '0';
|