diff options
| author | Adam Malczewski <[email protected]> | 2026-06-07 14:49:30 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-07 14:49:30 +0900 |
| commit | 56d4841ef1b4e3c5b940b23562f54c9858d35636 (patch) | |
| tree | 9b53fa29747fae903b8c00799df948d1bdb1b779 /src/features/tabs/tabs.test.ts | |
| parent | 34bed91f2e0ee2484df6be9d2fc8742f64b24941 (diff) | |
| download | dispatch-web-56d4841ef1b4e3c5b940b23562f54c9858d35636.tar.gz dispatch-web-56d4841ef1b4e3c5b940b23562f54c9858d35636.zip | |
feat(tabs): polish new-chat button — stuck-only square edge, New Chat label
- isStuckToEnd (pure): square the sticky '+' right edge only while it floats
over scrolled tabs; rounded at rest. Edge-measured in TabBar via a disposed
scroll + ResizeObserver effect (RO guarded for non-browser envs).
- Show a temporary 'New Chat' title when the draft is selected, with the '+'
moved to the trailing close-button slot for consistency with real tabs.
Diffstat (limited to 'src/features/tabs/tabs.test.ts')
| -rw-r--r-- | src/features/tabs/tabs.test.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/features/tabs/tabs.test.ts b/src/features/tabs/tabs.test.ts index 3034e76..5effa9b 100644 --- a/src/features/tabs/tabs.test.ts +++ b/src/features/tabs/tabs.test.ts @@ -6,6 +6,7 @@ import { createTab, deriveTitle, initialState, + isStuckToEnd, newDraft, selectTab, setModel, @@ -189,3 +190,26 @@ describe("deriveTitle", () => { expect(result).toBe(`${"a".repeat(40)}\u2026`); }); }); + +describe("isStuckToEnd", () => { + it("is false when the strip does not overflow", () => { + expect(isStuckToEnd({ scrollLeft: 0, clientWidth: 500, scrollWidth: 500 })).toBe(false); + expect(isStuckToEnd({ scrollLeft: 0, clientWidth: 500, scrollWidth: 400 })).toBe(false); + }); + + it("is true when overflowing and scrolled to the left", () => { + expect(isStuckToEnd({ scrollLeft: 0, clientWidth: 500, scrollWidth: 1000 })).toBe(true); + }); + + it("is true when overflowing and scrolled to the middle", () => { + expect(isStuckToEnd({ scrollLeft: 250, clientWidth: 500, scrollWidth: 1000 })).toBe(true); + }); + + it("is false when overflowing but scrolled fully to the right", () => { + expect(isStuckToEnd({ scrollLeft: 500, clientWidth: 500, scrollWidth: 1000 })).toBe(false); + }); + + it("treats a 1px subpixel gap at the end as at-rest (epsilon)", () => { + expect(isStuckToEnd({ scrollLeft: 499, clientWidth: 500, scrollWidth: 1000 })).toBe(false); + }); +}); |
