Skip to content

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.

fix(ui): switch to emoji without tearing down the clipboard list

Deepender25cf36e5f1c557
diff --git a/src/components/EmojiPicker.tsx b/src/components/EmojiPicker.tsx
index 72d68fb..e6e9d2a 100644
--- a/src/components/EmojiPicker.tsx
+++ b/src/components/EmojiPicker.tsx
@@ -74,7 +74,7 @@ function Glyph({ file, size = 22 }: { file: string; size?: number }) {
)
}
-export function EmojiPicker() {
+export function EmojiPicker({ active = true }: { active?: boolean }) {
const { t } = useTranslation()
const pasteEmoji = useStore((s) => s.pasteEmoji)
const category = useStore((s) => s.emojiCategory)
@@ -132,13 +132,18 @@ export function EmojiPicker() {
}, [category])
useEffect(() => {
+ if (!active || !catalog) return
const el = scrollerRef.current
if (!el) return
- const ro = new ResizeObserver(() => setViewH(el.clientHeight))
+ const apply = () => {
+ const h = el.clientHeight
+ if (h > 0) setViewH(h)
+ }
+ const ro = new ResizeObserver(apply)
ro.observe(el)
- setViewH(el.clientHeight)
+ apply()
return () => ro.disconnect()
- }, [catalog])
+ }, [catalog, active])
const items = useMemo(() => {
if (!catalog) return [] as Array<{ key: string; file: string; entry: EmojiEntry }>
diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index 0b7697c..c2eaaf0 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -3,6 +3,7 @@ import { motion } from 'framer-motion'
import { useStore } from '../store/appStore'
import { GearIcon, CloseIcon, InfoIcon, ClockIcon, TypeIcon, LinkIcon, ImageIcon, FilesIcon, EmojiSmileIcon } from './icons'
import { playButtonClickSound } from '../lib/soundEffects'
+import { loadEmojiCatalog } from '../lib/emoji/load'
import { useTranslation } from '../i18n'
@@ -117,6 +118,9 @@ export function Header() {
title={f.label}
aria-label={f.label}
aria-pressed={active}
+ onPointerEnter={() => {
+ if (f.id === 'emoji') void loadEmojiCatalog()
+ }}
onClick={() => {
playButtonClickSound()
if (f.id === 'emoji') setEmojiOpen(true)
diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx
index 4e96caa..459bb9d 100644
--- a/src/components/Panel.tsx
+++ b/src/components/Panel.tsx
@@ -39,6 +39,11 @@ export function Panel() {
const setQuery = useStore((s) => s.setQuery)
const emojiOpen = useStore((s) => s.emojiOpen)
const setEmojiOpen = useStore((s) => s.setEmojiOpen)
+ // Mount the picker on first open, then keep it. Tearing it (and ItemList)
+ // down on every smile click is what made the switch hitch.
+ const emojiMountedRef = useRef(false)
+ if (emojiOpen) emojiMountedRef.current = true
+ const emojiMounted = emojiMountedRef.current
const edgeHintActive = useStore((s) => s.edgeHintActive)
useEffect(() => {
@@ -361,14 +366,41 @@ export function Panel() {
</motion.div>
) : (
<motion.div
- key={emojiOpen ? 'emoji' : 'list'}
- initial={{ opacity: 0, y: emojiOpen ? 8 : -8 }}
+ key="main"
+ initial={{ opacity: 0, y: -8 }}
animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: emojiOpen ? -8 : 8 }}
+ exit={{ opacity: 0, y: 8 }}
transition={{ type: 'spring', stiffness: 500, damping: 32, mass: 0.5 }}
style={{ gridArea: '1 / 1 / 2 / 2', display: 'flex', flexDirection: 'column', overflow: 'hidden', position: 'relative' }}
>
- {emojiOpen ? <EmojiPicker /> : <ItemList />}
+ <div style={{ flex: 1, minHeight: 0, display: 'grid', gridTemplate: '1fr / 1fr', overflow: 'hidden' }}>
+ <div
+ style={{
+ gridArea: '1 / 1 / 2 / 2',
+ display: emojiOpen ? 'none' : 'flex',
+ flexDirection: 'column',
+ minHeight: 0,
+ height: '100%',
+ overflow: 'hidden'
+ }}
+ aria-hidden={emojiOpen}
+ >
+ <ItemList />
+ </div>
+ <div
+ style={{
+ gridArea: '1 / 1 / 2 / 2',
+ display: emojiOpen ? 'flex' : 'none',
+ flexDirection: 'column',
+ minHeight: 0,
+ height: '100%',
+ overflow: 'hidden'
+ }}
+ aria-hidden={!emojiOpen}
+ >
+ {emojiMounted ? <EmojiPicker active={emojiOpen} /> : null}
+ </div>
+ </div>
<div className="footer" style={{ position: 'relative' }}>
{!emojiOpen && (
<>