BlueGit

timfa filemanager

Merge feature/file-tile-name-wrap-clamp

timfa Tim Falken · pushed by timfa

Authored 2026-05-18 · 6 months ago

Hash
54e35287aa6d1d722915adf2b2928431549fb023
4 files changed +62 −2
.github/technical-reference.md +1 −0
@@ -239,6 +239,7 @@
239 239 - loadMoveChildren(containerEl, dirPath) - Lazy-loads subfolders for a tree node via /api/files/list.
240 240 - isInlinePreviewableBlob(blob, name) - Determines if a blob can be previewed inline by MIME/extension.
241 241 - makeFileItem(item) - Builds a .file-item element; roots in Home now use folder-like interaction (single-click focus, double-click open), roots are non-draggable, and mobile long-press contextmenu suppression remains.
242 - makeFileItem(item) / renderFileItemName(targetEl, fileName) - Renders tile names with preferred wrap opportunities (space first, then `-`, `,`, `.` via `<wbr>` hints) and preserves original visible text; tile-name CSS clamps to 4 lines with truncation.
242 243 - makeFileItem(item) - Renders tile icons first, then applies any cached watched overlay state (`fully` full-size filled eye, `partway` smaller darker filled eye).
243 244 - loadWatchedStatusesForCurrentDir() - Fetches watched states in one bulk POST /files/watched-statuses request per directory (with legacy /files/meta fallback), caches statuses per path, and updates tile overlays quickly.
244 245 - attachMobileLongPress(el, item) - Adds mobile long-press detection on file/folder tiles to open the item sidebar without desktop side effects.
@@ -239,6 +239,7 @@
239- loadMoveChildren(containerEl, dirPath) - Lazy-loads subfolders for a tree node via /api/files/list.
239- loadMoveChildren(containerEl, dirPath) - Lazy-loads subfolders for a tree node via /api/files/list.
240- isInlinePreviewableBlob(blob, name) - Determines if a blob can be previewed inline by MIME/extension.
240- isInlinePreviewableBlob(blob, name) - Determines if a blob can be previewed inline by MIME/extension.
241- makeFileItem(item) - Builds a .file-item element; roots in Home now use folder-like interaction (single-click focus, double-click open), roots are non-draggable, and mobile long-press contextmenu suppression remains.
241- makeFileItem(item) - Builds a .file-item element; roots in Home now use folder-like interaction (single-click focus, double-click open), roots are non-draggable, and mobile long-press contextmenu suppression remains.
242- makeFileItem(item) / renderFileItemName(targetEl, fileName) - Renders tile names with preferred wrap opportunities (space first, then `-`, `,`, `.` via `<wbr>` hints) and preserves original visible text; tile-name CSS clamps to 4 lines with truncation.
242- makeFileItem(item) - Renders tile icons first, then applies any cached watched overlay state (`fully` full-size filled eye, `partway` smaller darker filled eye).
243- makeFileItem(item) - Renders tile icons first, then applies any cached watched overlay state (`fully` full-size filled eye, `partway` smaller darker filled eye).
243- loadWatchedStatusesForCurrentDir() - Fetches watched states in one bulk POST /files/watched-statuses request per directory (with legacy /files/meta fallback), caches statuses per path, and updates tile overlays quickly.
244- loadWatchedStatusesForCurrentDir() - Fetches watched states in one bulk POST /files/watched-statuses request per directory (with legacy /files/meta fallback), caches statuses per path, and updates tile overlays quickly.
244- attachMobileLongPress(el, item) - Adds mobile long-press detection on file/folder tiles to open the item sidebar without desktop side effects.
245- attachMobileLongPress(el, item) - Adds mobile long-press detection on file/folder tiles to open the item sidebar without desktop side effects.
public/app.js +22 −1
@@ -2303,6 +2303,27 @@ function makeGroupSeparator (label)
2303 2303 return el;
2304 2304 }
2305 2305
2306 function renderFileItemName (targetEl, fileName)
2307 {
2308 if (!targetEl) return;
2309
2310 const rawName = String(fileName || '');
2311 targetEl.textContent = '';
2312 if (!rawName) return;
2313
2314 const segments = rawName.split(/([\-.,])/);
2315 for (const segment of segments)
2316 {
2317 if (!segment) continue;
2318 targetEl.appendChild(document.createTextNode(segment));
2319
2320 if (segment === '-' || segment === ',' || segment === '.')
2321 {
2322 targetEl.appendChild(document.createElement('wbr'));
2323 }
2324 }
2325 }
2326
2306 2327 function renderFileGrid ()
2307 2328 {
2308 2329 if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
@@ -2356,7 +2377,7 @@ function makeFileItem (item)
2356 2377
2357 2378 const name = document.createElement('div');
2358 2379 name.className = 'name';
2359 name.textContent = item.name;
2380 renderFileItemName(name, item.name);
2360 2381 el.appendChild(name);
2361 2382
2362 2383 if (!item._root) makeDraggable(el, item);
@@ -2303,6 +2303,27 @@ function makeGroupSeparator (label)
2303 return el;
2303 return el;
2304}
2304}
2305
2305
2306function renderFileItemName (targetEl, fileName)
2307{
2308 if (!targetEl) return;
2309
2310 const rawName = String(fileName || '');
2311 targetEl.textContent = '';
2312 if (!rawName) return;
2313
2314 const segments = rawName.split(/([\-.,])/);
2315 for (const segment of segments)
2316 {
2317 if (!segment) continue;
2318 targetEl.appendChild(document.createTextNode(segment));
2319
2320 if (segment === '-' || segment === ',' || segment === '.')
2321 {
2322 targetEl.appendChild(document.createElement('wbr'));
2323 }
2324 }
2325}
2326
2306function renderFileGrid ()
2327function renderFileGrid ()
2307{
2328{
2308 if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
2329 if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
@@ -2356,7 +2377,7 @@ function makeFileItem (item)
2356
2377
2357 const name = document.createElement('div');
2378 const name = document.createElement('div');
2358 name.className = 'name';
2379 name.className = 'name';
2359 name.textContent = item.name;
2380 renderFileItemName(name, item.name);
2360 el.appendChild(name);
2381 el.appendChild(name);
2361
2382
2362 if (!item._root) makeDraggable(el, item);
2383 if (!item._root) makeDraggable(el, item);
public/style.css +10 −1
@@ -560,10 +560,19 @@ button.danger.admin-update-highlight {
560 560
561 561 .file-item .name {
562 562 font-size: 0.8rem;
563 word-break: break-all;
563 word-break: normal;
564 overflow-wrap: anywhere;
564 565 max-width: 100%;
565 566 line-height: 1.3;
566 567 color: var(--text);
568 white-space: normal;
569 overflow: hidden;
570 text-overflow: ellipsis;
571 max-height: calc(1.3em * 4);
572 display: -webkit-box;
573 -webkit-box-orient: vertical;
574 -webkit-line-clamp: 4;
575 line-clamp: 4;
567 576 }
568 577
569 578 /* =========================================================
@@ -560,10 +560,19 @@ button.danger.admin-update-highlight {
560
560
561.file-item .name {
561.file-item .name {
562 font-size: 0.8rem;
562 font-size: 0.8rem;
563 word-break: break-all;
563 word-break: normal;
564 overflow-wrap: anywhere;
564 max-width: 100%;
565 max-width: 100%;
565 line-height: 1.3;
566 line-height: 1.3;
566 color: var(--text);
567 color: var(--text);
568 white-space: normal;
569 overflow: hidden;
570 text-overflow: ellipsis;
571 max-height: calc(1.3em * 4);
572 display: -webkit-box;
573 -webkit-box-orient: vertical;
574 -webkit-line-clamp: 4;
575 line-clamp: 4;
567}
576}
568
577
569/* =========================================================
578/* =========================================================
tests/page.load.test.js +29 −0
@@ -870,6 +870,35 @@ describe('page load smoke test', () =>
870 870 dom.window.close();
871 871 });
872 872
873 test('file tile names add preferred wrap hints at punctuation delimiters', async () =>
874 {
875 const longName = 'very-long-file.name,part-two-with-extra-sections.mp4';
876 listFixture = {
877 '/data': [
878 {
879 name: longName,
880 path: `/data/${longName}`,
881 isDir: false,
882 size: 1024,
883 mtime: Date.now(),
884 },
885 ],
886 };
887
888 const { dom, runtimeErrors } = await bootClient();
889 expect(runtimeErrors).toEqual([]);
890
891 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item .name'));
892 const nameEl = dom.window.document.querySelector('.file-item .name');
893 expect(nameEl).toBeTruthy();
894 expect(nameEl.textContent).toBe(longName);
895
896 const wbrs = nameEl.querySelectorAll('wbr');
897 expect(wbrs.length).toBeGreaterThan(0);
898
899 dom.window.close();
900 });
901
873 902 test('shows pending icon spinner when video thumbnail cache is not ready', async () =>
874 903 {
875 904 listFixture = {
@@ -870,6 +870,35 @@ describe('page load smoke test', () =>
870 dom.window.close();
870 dom.window.close();
871 });
871 });
872
872
873 test('file tile names add preferred wrap hints at punctuation delimiters', async () =>
874 {
875 const longName = 'very-long-file.name,part-two-with-extra-sections.mp4';
876 listFixture = {
877 '/data': [
878 {
879 name: longName,
880 path: `/data/${longName}`,
881 isDir: false,
882 size: 1024,
883 mtime: Date.now(),
884 },
885 ],
886 };
887
888 const { dom, runtimeErrors } = await bootClient();
889 expect(runtimeErrors).toEqual([]);
890
891 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item .name'));
892 const nameEl = dom.window.document.querySelector('.file-item .name');
893 expect(nameEl).toBeTruthy();
894 expect(nameEl.textContent).toBe(longName);
895
896 const wbrs = nameEl.querySelectorAll('wbr');
897 expect(wbrs.length).toBeGreaterThan(0);
898
899 dom.window.close();
900 });
901
873 test('shows pending icon spinner when video thumbnail cache is not ready', async () =>
902 test('shows pending icon spinner when video thumbnail cache is not ready', async () =>
874 {
903 {
875 listFixture = {
904 listFixture = {