Spaces:
Sleeping
Sleeping
thadillo
commited on
Commit
·
c6befa6
1
Parent(s):
47ac3f3
Fix: Remove autofocus warning in iframe
Browse files- Replace autofocus attribute with JavaScript focus
- Add try-catch to silently handle iframe blocking
- Improves UX when embedded in Hugging Face Spaces
Removes browser console warning about blocked autofocus
- app/templates/login.html +12 -1
app/templates/login.html
CHANGED
|
@@ -27,12 +27,23 @@
|
|
| 27 |
<div class="mb-3">
|
| 28 |
<label for="token" class="form-label">Access Token</label>
|
| 29 |
<input type="text" class="form-control form-control-lg" id="token" name="token"
|
| 30 |
-
placeholder="Enter your token" required
|
| 31 |
</div>
|
| 32 |
|
| 33 |
<button type="submit" class="btn btn-primary btn-lg w-100">Login</button>
|
| 34 |
</form>
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
<div class="mt-4 pt-4 border-top text-center">
|
| 37 |
<a href="{{ url_for('auth.generate') }}" class="btn btn-success btn-sm">
|
| 38 |
<i class="bi bi-key-fill"></i> Don't have a token? Generate one here
|
|
|
|
| 27 |
<div class="mb-3">
|
| 28 |
<label for="token" class="form-label">Access Token</label>
|
| 29 |
<input type="text" class="form-control form-control-lg" id="token" name="token"
|
| 30 |
+
placeholder="Enter your token" required>
|
| 31 |
</div>
|
| 32 |
|
| 33 |
<button type="submit" class="btn btn-primary btn-lg w-100">Login</button>
|
| 34 |
</form>
|
| 35 |
|
| 36 |
+
<script>
|
| 37 |
+
// Focus input field with delay to work in iframes
|
| 38 |
+
setTimeout(function() {
|
| 39 |
+
try {
|
| 40 |
+
document.getElementById('token').focus();
|
| 41 |
+
} catch(e) {
|
| 42 |
+
// Silently fail if blocked by browser
|
| 43 |
+
}
|
| 44 |
+
}, 100);
|
| 45 |
+
</script>
|
| 46 |
+
|
| 47 |
<div class="mt-4 pt-4 border-top text-center">
|
| 48 |
<a href="{{ url_for('auth.generate') }}" class="btn btn-success btn-sm">
|
| 49 |
<i class="bi bi-key-fill"></i> Don't have a token? Generate one here
|