fix: resolve brain dump popup display bug, dismiss handlers, and form submission

- Fix CSS rule for .completion-overlay[hidden] and global [hidden] so overlays stay hidden on load
- Refactor brain dump quick capture into a standard semantic HTML <form> with submit button and close button
- Wire quick capture form submission to inboxItems and saveInbox() so items persist to the brain dump inbox
- Add click-outside (backdrop click) dismiss handlers for quick capture, morning sweep, unstuck modal, and timer complete
- Add global Escape key dismiss handler that closes any active modal or overlay even when typing in input
This commit is contained in:
djg 2026-09-23 19:50:26 +00:00
parent 0200cf65cd
commit bf76074c7b
3 changed files with 137 additions and 40 deletions

View file

@ -43,14 +43,18 @@
</div>
<!-- Quick Capture Overlay -->
<div id="quick-capture-overlay" class="completion-overlay" hidden>
<div id="quick-capture-overlay" class="completion-overlay" role="dialog" aria-modal="true" aria-labelledby="quick-capture-title" hidden>
<div class="completion-card">
<h2>Brain Dump (Parking Lot)</h2>
<p style="margin-top:-5px; font-size:0.9rem; color:var(--dim);">Clear your mind. We'll save it to your unsorted list.</p>
<input type="text" id="quick-capture-input" placeholder="What's distracting you?" autocomplete="off" style="width:100%;font-size:1.2rem;padding:15px;background:var(--bg-hover);border:2px solid var(--border);color:var(--text);border-radius:8px;margin-bottom:10px;margin-top:15px;" />
<div style="text-align:right;">
<span class="tiny dim">Press Esc to cancel, Enter to save</span>
</div>
<button id="quick-capture-close" class="modal-close" aria-label="Close dialog" type="button">×</button>
<h2 id="quick-capture-title">Brain Dump (Parking Lot)</h2>
<p style="margin-top:-5px; font-size:0.9rem; color:var(--dim);">Clear your mind. We'll save it to your brain dump inbox.</p>
<form id="quick-capture-form" action="#" style="margin-top:15px;">
<input type="text" id="quick-capture-input" name="task" placeholder="What's distracting you?" autocomplete="off" required style="width:100%;font-size:1.1rem;padding:12px 14px;background:var(--bg2);border:1.5px solid var(--line);color:var(--text);border-radius:10px;margin-bottom:14px;outline:none;" />
<div class="row between center gap" style="margin-top:4px;">
<span class="tiny dim">Press Esc to cancel, Enter to save</span>
<button type="submit" class="btn primary" id="quick-capture-submit">Save thought</button>
</div>
</form>
</div>
</div>
</header>

View file

@ -589,6 +589,12 @@
nowShowNext(true);
});
$('#timer-complete').addEventListener('click', function (e) {
if (e.target === this) {
this.hidden = true;
}
});
timerPaint();
/* ---------- dopamine menu ---------- */
@ -1044,11 +1050,19 @@
};
if (closeBtn) {
closeBtn.onclick = function () {
modal.hidden = true;
}
closeBtn.onclick = function () {
modal.hidden = true;
if (!isManual) stampVisit();
};
}
modal.onclick = function (e) {
if (e.target === modal) {
modal.hidden = true;
if (!isManual) stampVisit();
}
};
modal.hidden = false;
}
@ -1068,39 +1082,107 @@
});
}
/* ---------- quick capture overlay ---------- */
var $qcOverlay = $('#quick-capture-overlay'),
$qcForm = $('#quick-capture-form'),
$qcInput = $('#quick-capture-input'),
$qcClose = $('#quick-capture-close');
function openQuickCapture() {
if (!$qcOverlay) return;
$qcOverlay.hidden = false;
if ($qcInput) {
$qcInput.value = '';
setTimeout(function () { $qcInput.focus(); }, 50);
}
}
function closeQuickCapture() {
if (!$qcOverlay) return;
$qcOverlay.hidden = true;
if ($qcInput) $qcInput.value = '';
}
if ($qcForm) {
$qcForm.addEventListener('submit', function (e) {
e.preventDefault();
if (!$qcInput) return;
var val = $qcInput.value.trim();
if (!val) return;
inboxItems.unshift(val);
saveInbox();
closeQuickCapture();
tickSound();
});
}
if ($qcClose) {
$qcClose.addEventListener('click', closeQuickCapture);
}
if ($qcOverlay) {
$qcOverlay.addEventListener('click', function (e) {
if (e.target === this) {
closeQuickCapture();
}
});
}
/* ---------- keyboard shortcuts ---------- */
document.addEventListener('keydown', function (e) {
// Escape closes any open modal/overlay regardless of current focus
if (e.key === 'Escape') {
var qc = document.getElementById('quick-capture-overlay');
if (qc && !qc.hidden) {
closeQuickCapture();
e.preventDefault();
return;
}
var sweep = document.getElementById('sweep-modal');
if (sweep && !sweep.hidden) {
sweep.hidden = true;
if (typeof stampVisit === 'function') stampVisit();
e.preventDefault();
return;
}
var unstuck = document.getElementById('unstuck-modal');
if (unstuck && !unstuck.hidden) {
unstuck.hidden = true;
if (typeof unstuckInterval !== 'undefined') clearInterval(unstuckInterval);
if (typeof breathInterval !== 'undefined') clearInterval(breathInterval);
e.preventDefault();
return;
}
var tc = document.getElementById('timer-complete');
if (tc && !tc.hidden) {
tc.hidden = true;
e.preventDefault();
return;
}
var ambPanel = document.getElementById('ambient-panel');
if (ambPanel && !ambPanel.hidden) {
ambPanel.hidden = true;
e.preventDefault();
return;
}
}
// Quick Capture (Alt+P) - active globally
if (e.altKey && (e.key === 'p' || e.key === 'P')) {
e.preventDefault();
var overlay = document.getElementById('quick-capture-overlay');
if (overlay.hidden) {
overlay.hidden = false;
document.getElementById('quick-capture-input').value = '';
document.getElementById('quick-capture-input').focus();
if ($qcOverlay && $qcOverlay.hidden) {
openQuickCapture();
} else {
overlay.hidden = true;
closeQuickCapture();
}
return;
}
// Quick capture handling inside input
if (e.target.id === 'quick-capture-input') {
if (e.key === 'Escape') {
document.getElementById('quick-capture-overlay').hidden = true;
} else if (e.key === 'Enter' && e.target.value.trim() !== '') {
var unTasks = store('unsorted_tasks') || [];
unTasks.push({ text: e.target.value.trim(), created: Date.now() });
store('unsorted_tasks', unTasks);
if (typeof unPaint === 'function') unPaint();
document.getElementById('quick-capture-overlay').hidden = true;
e.target.value = '';
}
}
// Don't trigger shortcuts when typing in an input or contenteditable
// Don't trigger standard navigation shortcuts when typing in an input or contenteditable
var tag = e.target.tagName;
if (tag === 'INPUT' || tag === 'TEXTAREA' || e.target.contentEditable === 'true') return;
// Number keys 1-4 switch tabs
// Number keys 1-5 switch tabs
if (e.key === '1') { showTab('breaker'); e.preventDefault(); }
if (e.key === '2') { showTab('timer'); e.preventDefault(); }
if (e.key === '3') { showTab('dopamine'); e.preventDefault(); }
@ -1112,14 +1194,6 @@
e.preventDefault();
$('#timer-start').click();
}
// Escape to close completion overlay
if (e.key === 'Escape') {
var overlay = $('#timer-complete');
if (overlay && !overlay.hidden) {
overlay.hidden = true;
}
}
});
@ -1309,6 +1383,14 @@
clearInterval(breathInterval);
});
modal.addEventListener('click', (e) => {
if (e.target === modal) {
modal.hidden = true;
clearInterval(unstuckInterval);
clearInterval(breathInterval);
}
});
// Proceed from phase 1 to 2
$('#unstuck-next-1').addEventListener('click', () => {
p1.hidden = true;

View file

@ -1,5 +1,6 @@
/* myadhd.dev — calm, low-stimulation dark theme */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
--bg: #14141c;
--bg2: #1b1b26;
@ -182,10 +183,14 @@ input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-off
display: flex; align-items: center; justify-content: center;
animation: fadeIn 0.3s ease;
}
.completion-overlay[hidden] {
display: none !important;
}
.completion-card {
background: var(--card); border: 1.5px solid var(--accent-dim);
border-radius: var(--radius); padding: 40px 32px;
max-width: 400px; text-align: center;
position: relative;
animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.completion-emoji { font-size: 3rem; margin-bottom: 12px; }
@ -319,11 +324,17 @@ input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-off
text-align: center;
box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.close-modal {
.close-modal, .modal-close {
position: absolute;
top: 15px; right: 20px;
background: none; border: none; font-size: 28px;
color: var(--text-muted, #a6adc8); cursor: pointer;
line-height: 1;
padding: 4px;
transition: color 0.15s ease;
}
.close-modal:hover, .modal-close:hover {
color: var(--text, #e6e6f0);
}
.unstuck-phase h2 { margin-top: 0; color: var(--text-main, #cdd6f4); margin-bottom: 15px; }
.unstuck-phase p { color: var(--text-main, #bac2de); margin-bottom: 25px; font-size: 1.1em; line-height: 1.4;}