Skip to content

Commit da2933b

Browse files
committed
🐛 Fix critical file upload and download issues
- Fix file input click handler - enable pointer-events on upload-content - Add direct click handler on upload-content element - Add automatic scroll to results after file processing - Improve download button event handling with better error checking - Replace alert with toast notification for better UX - Reset file input after selection to allow re-selecting same file - Update cache-busting to v=4
1 parent c042325 commit da2933b

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

docs/assets/app.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,22 @@ class App {
192192
}
193193
// Trigger file input click
194194
if (this.fileInput) {
195+
e.preventDefault();
196+
e.stopPropagation();
195197
this.fileInput.click();
196198
}
197199
});
200+
201+
// Also make upload-content clickable (bypass pointer-events: none)
202+
const uploadContent = this.uploadArea.querySelector('.upload-content');
203+
if (uploadContent) {
204+
uploadContent.addEventListener('click', (e) => {
205+
e.stopPropagation();
206+
if (this.fileInput) {
207+
this.fileInput.click();
208+
}
209+
});
210+
}
198211

199212
// Drag and drop
200213
this.uploadArea.addEventListener('dragover', (e) => {
@@ -229,13 +242,18 @@ class App {
229242
);
230243

231244
if (validFiles.length === 0) {
232-
alert('Please upload .txt or .docx files only.');
245+
this.showToast('Please upload .txt or .docx files only.', 'error');
233246
return;
234247
}
235248

236249
this.files.push(...validFiles);
237250
this.updateFileList();
238251
this.processFiles();
252+
253+
// Reset file input to allow selecting the same file again
254+
if (this.fileInput) {
255+
this.fileInput.value = '';
256+
}
239257
}
240258

241259
updateFileList() {
@@ -304,6 +322,11 @@ class App {
304322

305323
this.results = results;
306324
this.displayResults(results, totalStats);
325+
326+
// Scroll to results section after processing
327+
setTimeout(() => {
328+
this.resultsSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
329+
}, 100);
307330
}
308331

309332
displayResults(results, totalStats) {
@@ -384,15 +407,19 @@ class App {
384407
// Setup download and copy buttons
385408
document.querySelectorAll('.download-btn').forEach(btn => {
386409
btn.addEventListener('click', (e) => {
387-
const index = parseInt(e.target.dataset.index);
388-
this.downloadFile(results[index]);
410+
const index = parseInt(e.target.dataset.index || e.target.closest('.download-btn').dataset.index);
411+
if (results[index]) {
412+
this.downloadFile(results[index]);
413+
}
389414
});
390415
});
391416

392417
document.querySelectorAll('.copy-btn').forEach(btn => {
393418
btn.addEventListener('click', (e) => {
394-
const index = parseInt(e.target.dataset.index);
395-
this.copyToClipboard(results[index].cleanedText);
419+
const index = parseInt(e.target.dataset.index || e.target.closest('.copy-btn').dataset.index);
420+
if (results[index]) {
421+
this.copyToClipboard(results[index].cleanedText);
422+
}
396423
});
397424
});
398425
}

docs/assets/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ body {
170170
}
171171

172172
.upload-content {
173-
pointer-events: none;
173+
pointer-events: auto;
174174
user-select: none;
175+
cursor: pointer;
175176
}
176177

177178
.upload-icon {

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>DocStripper - Batch Document Cleaner</title>
77
<meta name="description" content="DocStripper - Remove noise from text documents automatically. Clean page numbers, headers, footers, duplicates, and empty lines.">
8-
<link rel="stylesheet" href="assets/style.css?v=3">
8+
<link rel="stylesheet" href="assets/style.css?v=4">
99
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🧹</text></svg>">
1010
</head>
1111
<body>
@@ -180,6 +180,6 @@ <h2>Prefer Command Line?</h2>
180180
</div>
181181
</footer>
182182

183-
<script src="assets/app.js?v=3"></script>
183+
<script src="assets/app.js?v=4"></script>
184184
</body>
185185
</html>

0 commit comments

Comments
 (0)