fixing ctrl+enter on comments not giving a error

This commit is contained in:
2026-05-13 13:52:45 +02:00
parent a968de01d5
commit d476a002d8

View File

@@ -2011,10 +2011,17 @@ window.initUploadForm = (selector) => {
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
if (e.key !== 'Enter' || (!e.ctrlKey && !e.metaKey)) return; if (e.key !== 'Enter' || (!e.ctrlKey && !e.metaKey)) return;
// If the focused element is a textarea or input that is NOT inside an upload form,
// do not interfere — it belongs to comments, chat, or another feature.
const active = document.activeElement;
if (active && (active.tagName === 'TEXTAREA' || active.tagName === 'INPUT')) {
if (!active.closest('.upload-form')) return;
}
// 1. Try the element that currently has focus // 1. Try the element that currently has focus
// 2. Fall back to the modal form if it's visible // 2. Fall back to the modal form if it's visible
// 3. Fall back to any visible upload form on the page // 3. Fall back to any visible upload form on the page
let targetForm = document.activeElement?.closest('.upload-form'); let targetForm = active?.closest('.upload-form');
if (!targetForm || !targetForm._f0ckUploader) { if (!targetForm || !targetForm._f0ckUploader) {
const modal = document.getElementById('upload-drag-modal'); const modal = document.getElementById('upload-drag-modal');