Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.
TypeScript clipboardclipboard-managerdesktop-appdrag-and-dropelectronopen-sourceproductivityproductivity-toolwindows
fix(list): cards in view stay drawn, so the top dock never opens on empty cards
Deepender25767b6d63d784
diff --git a/src/components/ItemList.tsx b/src/components/ItemList.tsxindex 8442adc..d9b1492 100644--- a/src/components/ItemList.tsx+++ b/src/components/ItemList.tsx@@ -451,6 +451,42 @@ export function ItemList() {el.animate([{ opacity: 0.45 }, { opacity: 1 }], { duration: 120, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' })}, [filterKey, hasStack])+ // Cards in or near the list's view are marked data-near and always drawn+ // (item.css); the rest stay culled by content-visibility: auto. Left to+ // content-visibility alone, the top dock painted its cards as empty boxes+ // on every open until the open motion (the blade's clip-path growing from+ // the edge bar) ended, about 5 frames; drawing them fully removes that. This+ // observer measures against the list itself, which the clip does not touch,+ // so the cards in view stay drawn while the shelf is closed.+ useEffect(() => {+ const list = listRef.current+ const stack = stackRef.current+ if (!list || !stack || typeof IntersectionObserver !== 'function') return+ const near = new IntersectionObserver(+ (entries) => {+ for (const e of entries) {+ if (e.isIntersecting) e.target.setAttribute('data-near', '')+ else e.target.removeAttribute('data-near')+ }+ },+ // one view either side, along the list's own direction+ { root: list, rootMargin: isHorizontal ? '0px 100% 0px 100%' : '100% 0px 100% 0px' }+ )+ const watched = new Set<Element>()+ const sync = () => {+ const cards = new Set(stack.querySelectorAll('.item'))+ for (const card of cards) if (!watched.has(card)) { near.observe(card); watched.add(card) }+ for (const card of watched) if (!cards.has(card)) { near.unobserve(card); watched.delete(card) }+ }+ sync()+ const added = new MutationObserver(sync)+ added.observe(stack, { childList: true, subtree: true })+ return () => {+ added.disconnect()+ near.disconnect()+ }+ }, [hasStack, isHorizontal])+return (<divclassName={`list${isHorizontal ? ' horizontal' : ''}`}diff --git a/src/styles/item.css b/src/styles/item.cssindex fd253bc..a9aef31 100644--- a/src/styles/item.css+++ b/src/styles/item.css@@ -59,6 +59,12 @@content-visibility: auto;contain-intrinsic-size: auto 96px;}+/* Cards in or near the list's view (ItemList marks them, measured against+ the list, not the window) are always drawn, so opening the shelf never+ shows them empty while its clip is still growing. */+.list-stack .item[data-near] {+ content-visibility: visible;+}.list-stack .item.is-expanded {content-visibility: visible !important;diff --git a/tests/cardCulling.test.ts b/tests/cardCulling.test.tsnew file mode 100644index 0000000..5b488bc--- /dev/null+++ b/tests/cardCulling.test.ts@@ -0,0 +1,31 @@+import { describe, expect, it } from 'vitest'+import { readFileSync } from 'node:fs'+import { join } from 'node:path'++// Cards are culled with content-visibility: auto, but the ones in or near the+// list's view are always drawn. Left to content-visibility alone, the top dock+// painted its cards as empty boxes on every open until the open motion ended.++const read = (p: string) => readFileSync(join(process.cwd(), p), 'utf8').replace(/\r\n/g, '\n')+const list = read('src/components/ItemList.tsx')+const css = read('src/styles/item.css')++describe('cards in view stay drawn while the shelf is closed', () => {+ it('culls cards, except those marked data-near', () => {+ expect(css).toMatch(/\.list-stack \.item \{\s*content-visibility: auto;/)+ expect(css).toMatch(/\.list-stack \.item\[data-near\] \{\s*content-visibility: visible;/)+ })++ it('marks cards near the view measured against the list, not the window (the closed clip does not touch it)', () => {+ expect(list).toContain('new IntersectionObserver(')+ expect(list).toContain("{ root: list, rootMargin: isHorizontal ? '0px 100% 0px 100%' : '100% 0px 100% 0px' }")+ expect(list).toContain("if (e.isIntersecting) e.target.setAttribute('data-near', '')")+ expect(list).toContain("else e.target.removeAttribute('data-near')")+ })++ it('watches cards as they come and go, and lets go of them on unmount', () => {+ expect(list).toContain("const cards = new Set(stack.querySelectorAll('.item'))")+ expect(list).toContain('added.observe(stack, { childList: true, subtree: true })')+ expect(list).toMatch(/added\.disconnect\(\)\s*near\.disconnect\(\)/)+ })+})