MCPcopy Create free account
hub / github.com/error311/FileRise / wireModalEnterDefault

Function wireModalEnterDefault

public/js/main.js:335–359  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

333}
334
335function wireModalEnterDefault() {
336 if (window.__FR_FLAGS.wired.enterDefault) return;
337 window.__FR_FLAGS.wired.enterDefault = true;
338
339 document.addEventListener('keydown', (e) => {
340 if (e.key !== 'Enter' || e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) return;
341
342 // don’t hijack multiline inputs or anything explicitly opted-out
343 const tgt = e.target;
344 if (tgt && (tgt.tagName === 'TEXTAREA' || tgt.isContentEditable || tgt.closest('[data-no-enter]'))) return;
345
346 // pick the topmost visible modal
347 const modal = Array.from(document.querySelectorAll('.modal')).reverse().find(m => {
348 const s = getComputedStyle(m);
349 return s.display !== 'none' && s.visibility !== 'hidden' && s.pointerEvents !== 'none';
350 });
351 if (!modal) return;
352
353 const btn = modal.querySelector('[data-default]');
354 if (!btn || btn.disabled) return;
355
356 e.preventDefault();
357 btn.click();
358 }, true); // capture so we beat other handlers
359}
360
361const MODAL_SELECTORS = [
362 '.modal',

Callers 2

bootHeavyFunction · 0.85
main.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected