forge
Explore
Log in

Don't you dare go Hollow

the files pane takes the dropped hand: the Files tab's whole section is the upload box's hit area — the drag listeners resolve .file-upload-box or .files-pane and a drag caught anywhere in the section lands on the box inside it, which stays the one element that wears the accent mark, so the control signals while the pane catches and no pane-level paint is invented; a pane with no box (a viewer's files tab) is not a target, dragleave strips the mark only when the pointer leaves the zone itself, and the browser pass drives the mark, the unmark and a third file dropped on the list through the same change -> requestSubmit -> multipart XHR path to chips

Browse files at this commit

4f8f4539244cf2caa789ec0c597d9333f5ae0e5cAhmet Kaan GümüşParent: 506e525
crates/iz-web/src/detail.rsmodified+3 -1
@@ -2183,7 +2183,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab)
2183 }2183 }
2184 2184
2185 if tab == Tab::Files {2185 if tab == Tab::Files {
2186- <section class="detail-block">2186+ // The section is the upload box's hit area: layout.rs's
2187+ // drag listeners catch a file dropped anywhere in it.
2188+ <section class="detail-block files-pane">
2187 <div class="detail-block-head">2189 <div class="detail-block-head">
2188 <span class="detail-label">(t(lang, Key::Files))</span>2190 <span class="detail-label">(t(lang, Key::Files))</span>
2189 <span class="detail-count">(detail.files.len())</span>2191 <span class="detail-count">(detail.files.len())</span>
crates/iz-web/src/layout.rsmodified+17 -4
@@ -677,19 +677,32 @@ pub async fn soft_nav_script(cx: &Cx) -> Result {
677 } \677 } \
678 if (control.hasAttribute && control.hasAttribute('data-autosubmit')) { control.form.requestSubmit(); } \678 if (control.hasAttribute && control.hasAttribute('data-autosubmit')) { control.form.requestSubmit(); } \
679 }); \679 }); \
680+ // The Files tab's whole pane is the upload box's hit area: a drag
681+ // caught anywhere in `.files-pane` lands on the box inside it, and
682+ // the box is also the element that wears the mark — the control
683+ // signals, the pane catches. A pane with no box (a viewer's Files
684+ // tab) is not a target at all.
685+ function uploadBox(zone) { \
686+ return zone.classList.contains('files-pane') ? zone.querySelector('.file-upload-box') : zone; \
687+ } \
680 document.addEventListener('dragover', function (e) { \688 document.addEventListener('dragover', function (e) { \
681- var box = e.target.closest ? e.target.closest('.file-upload-box') : null; \689+ var zone = e.target.closest ? e.target.closest('.file-upload-box, .files-pane') : null; \
690+ var box = zone ? uploadBox(zone) : null; \
682 if (!box || !e.dataTransfer || e.dataTransfer.types.indexOf('Files') === -1) { return; } \691 if (!box || !e.dataTransfer || e.dataTransfer.types.indexOf('Files') === -1) { return; } \
683 e.preventDefault(); \692 e.preventDefault(); \
684 e.dataTransfer.dropEffect = 'copy'; \693 e.dataTransfer.dropEffect = 'copy'; \
685 window.__izOwn(box, ['file-upload-over'], []); \694 window.__izOwn(box, ['file-upload-over'], []); \
686 }); \695 }); \
687 document.addEventListener('dragleave', function (e) { \696 document.addEventListener('dragleave', function (e) { \
688- var box = e.target.closest ? e.target.closest('.file-upload-box') : null; \697+ var zone = e.target.closest ? e.target.closest('.file-upload-box, .files-pane') : null; \
689- if (box && !box.contains(e.relatedTarget)) { box.classList.remove('file-upload-over'); } \698+ if (zone && !zone.contains(e.relatedTarget)) { \
699+ var box = uploadBox(zone); \
700+ if (box) { box.classList.remove('file-upload-over'); } \
701+ } \
690 }); \702 }); \
691 document.addEventListener('drop', function (e) { \703 document.addEventListener('drop', function (e) { \
692- var box = e.target.closest ? e.target.closest('.file-upload-box') : null; \704+ var zone = e.target.closest ? e.target.closest('.file-upload-box, .files-pane') : null; \
705+ var box = zone ? uploadBox(zone) : null; \
693 if (!box) { return; } \706 if (!box) { return; } \
694 e.preventDefault(); \707 e.preventDefault(); \
695 box.classList.remove('file-upload-over'); \708 box.classList.remove('file-upload-over'); \
crates/iz-web/tests/browser/drop.mjsmodified+65 -1
@@ -9,6 +9,8 @@
9 // box, dragleave for the document body must unmark it, and a drop of two9 // box, dragleave for the document body must unmark it, and a drop of two
10 // files must ride the same change -> requestSubmit -> multipart XHR path10 // files must ride the same change -> requestSubmit -> multipart XHR path
11 // the picker uses — the landed chips are the proof, with zero page errors.11 // the picker uses — the landed chips are the proof, with zero page errors.
12+// The pane legs then repeat the same three over the Files tab's whole
13+// section, the box's hit area: a drop nowhere near the box still uploads.
12 //14 //
13 // Wants the server run.sh leaves behind, plus the session cookie it mints:15 // Wants the server run.sh leaves behind, plus the session cookie it mints:
14 // IZ_SESSION_COOKIE carries the sealed token the fake im knows — the same16 // IZ_SESSION_COOKIE carries the sealed token the fake im knows — the same
@@ -168,6 +170,68 @@ if (!failures.length) {
168 }170 }
169 }171 }
170 172
173+// The same hand, dropped on the pane instead of the box: the Files tab's
174+// whole section is the box's hit area, so a drag parked over the list or
175+// the head marks the box, leaving the pane for the body unmarks it, and a
176+// drop on the list rides the same change path. Dispatched on the head and
177+// list nodes — children of the pane — to prove the closest() resolution,
178+// not a lucky direct hit on the section itself.
179+if (!failures.length) {
180+ const paneOver = await page.evaluate(() => {
181+ const head = document.querySelector('.files-pane .detail-block-head');
182+ if (!head) return null;
183+ const dt = new DataTransfer();
184+ dt.items.add(new File(['iz three'], 'dropped-c.txt', { type: 'text/plain' }));
185+ head.dispatchEvent(new DragEvent('dragover', { bubbles: true, cancelable: true, dataTransfer: dt }));
186+ const box = document.querySelector('.file-upload-box');
187+ return box ? box.classList.contains('file-upload-over') : null;
188+ });
189+ if (paneOver !== true) {
190+ failures.push(`a dragover on the pane never marked the box (over=${paneOver})`);
191+ }
192+}
193+
194+if (!failures.length) {
195+ const paneGone = await page.evaluate(() => {
196+ const head = document.querySelector('.files-pane .detail-block-head');
197+ if (!head) return null;
198+ head.dispatchEvent(new DragEvent('dragleave', {
199+ bubbles: true, cancelable: true, relatedTarget: document.body,
200+ }));
201+ const box = document.querySelector('.file-upload-box');
202+ return box ? box.classList.contains('file-upload-over') : null;
203+ });
204+ if (paneGone !== false) failures.push(`dragleave off the pane never unmarked the box (over=${paneGone})`);
205+}
206+
207+if (!failures.length) {
208+ await page.evaluate(() => {
209+ const list = document.querySelector('.files-pane .file-list');
210+ if (!list) return;
211+ const dt = new DataTransfer();
212+ dt.items.add(new File(['iz three'], 'dropped-c.txt', { type: 'text/plain' }));
213+ list.dispatchEvent(new DragEvent('drop', { bubbles: true, cancelable: true, dataTransfer: dt }));
214+ });
215+ const paneDropped = await page
216+ .waitForFunction(
217+ () => {
218+ const names = [...document.querySelectorAll('.file-chip-name')]
219+ .map((el) => el.textContent.trim()).sort();
220+ return names.length === 3 && names[2] === 'dropped-c.txt';
221+ },
222+ { timeout: 10000 },
223+ )
224+ .then(() => true)
225+ .catch(() => false);
226+ if (!paneDropped) {
227+ const chips = await page.evaluate(() =>
228+ [...document.querySelectorAll('.file-chip-name')].map((el) => el.textContent.trim()));
229+ failures.push(`a drop on the pane never landed as a chip — chips: ${chips.join(' | ')}`);
230+ } else {
231+ await page.screenshot({ path: `${shots}/drop-pane.png` });
232+ }
233+}
234+
171 await browser.close();235 await browser.close();
172 236
173 note(`page errors ${errors.length ? errors.join(' | ') : 'none'}`);237 note(`page errors ${errors.length ? errors.join(' | ') : 'none'}`);
@@ -176,4 +240,4 @@ if (failures.length) {
176 for (const f of failures) note('FAIL ' + f);240 for (const f of failures) note('FAIL ' + f);
177 process.exit(1);241 process.exit(1);
178 }242 }
179-note('PASS the drop rides the real upload path: dragover marked the box, dragleave unmarked it, and both dropped files landed as chips');243+note('PASS the drop rides the real upload path: dragover marked the box, dragleave unmarked it, both dropped files landed as chips, and the pane itself caught a third');