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
feat(search): cleaner search field with a clear button in both docks
Deepender25852528f23226
diff --git a/src/components/ShelfSearch.tsx b/src/components/ShelfSearch.tsxindex 9874be3..daa0712 100644--- a/src/components/ShelfSearch.tsx+++ b/src/components/ShelfSearch.tsx@@ -16,7 +16,7 @@ import { useStore } from '../store/appStore'import { edge } from '../lib/edge'import { noteSearchEngaged } from '../lib/searchFocus'import { useTranslation } from '../i18n'-import { SearchIcon } from './icons'+import { CloseIcon, SearchIcon } from './icons'export function ShelfSearch() {const { t } = useTranslation()@@ -67,7 +67,7 @@ export function ShelfSearch() {}, [disengage])return (- <div className="search">+ <div className={`search${query ? ' has-query' : ''}`}><SearchIcon className="search-icon" width={14} height={14} /><inputref={inputRef}@@ -98,6 +98,27 @@ export function ShelfSearch() {}}spellCheck={false}/>+ {/* Clear (macOS search-field style). It must never touch focus: the+ OS-focus handover above is driven purely by the input's own+ focus/blur. So the button can't take focus (mousedown/pointerdown+ cancelled, out of the tab order; Escape clears from the keyboard)+ and it never calls focus() — after an app switch the page still+ remembers the input as focused, and refocusing it from here could+ pull OS focus back from the user's app. If the user was typing,+ the input simply keeps focus. Always mounted so it can fade. */}+ <button+ type="button"+ className="search-clear"+ aria-label={t('item.clear')}+ title={t('item.clear')}+ tabIndex={-1}+ aria-hidden={!query}+ onPointerDown={(e) => e.preventDefault()}+ onMouseDown={(e) => e.preventDefault()}+ onClick={() => setQuery('')}+ >+ <CloseIcon width={10} height={10} weight="bold" />+ </button></div>)}diff --git a/src/styles/panel.css b/src/styles/panel.cssindex 4045596..089e197 100644--- a/src/styles/panel.css+++ b/src/styles/panel.css@@ -239,41 +239,111 @@color: var(--text-primary);}-/* Search */+/* Search: borderless pill on the card surface. Focus lifts the fill a step+ further than hover and brightens the icon (no ring: the UI is borderless);+ a macOS-style clear button appears once there is text. */.search {+ --search-h: 34px;+ --search-font: 13px;+ --search-inset: 12px; /* icon / clear distance from the ends */margin: 4px var(--pad) 6px;position: relative;z-index: 1;}.search input {width: 100%;- height: 36px;- padding: 0 12px 0 34px;+ height: var(--search-h);+ padding: 0 calc(var(--search-inset) + 22px) 0 calc(var(--search-inset) + 22px);background: var(--bg-card);border: none;border-radius: var(--radius-pill);outline: none;color: var(--text-primary);- transition: background var(--dur-fast) var(--ease-out);+ caret-color: #ffffff;+ font-family: var(--font-ui);+ font-size: calc(var(--search-font) * var(--font-scale, 1));+ font-weight: 500;+ transition: background-color var(--dur-fast) var(--ease-out);}.search input::placeholder {color: var(--text-tertiary);+ font-weight: 400;}-.search input:focus {+.search input::selection {+ background: rgba(255, 255, 255, 0.28);+}+.search input:hover {background: var(--bg-card-hover);}+.search input:focus {+ background: #222222;+}.search .search-icon {position: absolute;- left: 11px;+ left: var(--search-inset);top: 50%;transform: translateY(-50%);color: var(--text-tertiary);pointer-events: none;+ transition: color var(--dur-fast) var(--ease-out);+}+.search:focus-within .search-icon,+.search.has-query .search-icon {+ color: rgba(255, 255, 255, 0.85);+}++/* Clear: grey disc with a dark cross, like a macOS search field. */+.search-clear {+ position: absolute;+ right: calc(var(--search-inset) - 2px);+ top: 50%;+ width: 18px;+ height: 18px;+ margin: -9px 0 0;+ padding: 0;+ display: grid;+ place-items: center;+ border: none;+ border-radius: 50%;+ background: rgba(255, 255, 255, 0.3);+ color: #141414;+ cursor: pointer;+ outline: none;+ opacity: 0;+ scale: 0.6;+ visibility: hidden;+ pointer-events: none;+ transition:+ opacity 0.12s ease,+ scale 0.16s cubic-bezier(0.2, 0.9, 0.3, 1),+ background-color 0.12s ease,+ visibility 0s linear 0.16s;+}+.search.has-query .search-clear {+ opacity: 1;+ scale: 1;+ visibility: visible;+ pointer-events: auto;+ transition:+ opacity 0.12s ease,+ scale 0.16s cubic-bezier(0.2, 0.9, 0.3, 1),+ background-color 0.12s ease,+ visibility 0s;+}+.search-clear:hover {+ background: rgba(255, 255, 255, 0.5);+}+.search-clear:active {+ scale: 0.9;+}+.search-clear:focus-visible {+ box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45);}/* Header-embedded search (horizontal dock): centered overlay, long field.Absolutely centered to the header so side widths can't offset it; fixed- width so focusing never shifts any neighboring buttons. */+ width so focusing never shifts any neighboring buttons. Same field, just+ the 30px control height and 12px text of that dock. */.header-search-center {position: absolute;left: 50%;@@ -284,17 +354,19 @@align-items: center;}.header-search-center .search {+ --search-h: 30px;+ --search-font: 12px;+ --search-inset: 10px;margin: 0;}.header-search-center .search input {- height: 30px;width: 300px;max-width: 100%;- padding: 0 10px 0 30px;- font-size: calc(12px * var(--font-scale, 1));}-.header-search-center .search .search-icon {- left: 9px;+.header-search-center .search-clear {+ width: 16px;+ height: 16px;+ margin-top: -8px;}/* Scroll area */diff --git a/tests/searchBar.test.ts b/tests/searchBar.test.tsnew file mode 100644index 0000000..cbf8d44--- /dev/null+++ b/tests/searchBar.test.ts@@ -0,0 +1,44 @@+import { describe, expect, it } from 'vitest'+import { readFileSync } from 'node:fs'+import { join } from 'node:path'++const read = (p: string) => readFileSync(join(__dirname, '..', p), 'utf8')+const tsx = read('src/components/ShelfSearch.tsx')+const css = read('src/styles/panel.css')++describe('search bar', () => {+ it('has a clear button that never touches focus and is labelled in every language', () => {+ expect(tsx).toContain('className="search-clear"')+ expect(tsx).toContain("aria-label={t('item.clear')}")+ // Can't take focus: press cancelled, out of the tab order.+ expect(tsx).toContain('onPointerDown={(e) => e.preventDefault()}')+ expect(tsx).toContain('onMouseDown={(e) => e.preventDefault()}')+ expect(tsx).toMatch(/className="search-clear"[\s\S]*?tabIndex=\{-1\}/)+ // Only clears. Refocusing the input from here could pull OS focus back+ // from the user's app after an app switch (the OS handover is driven+ // purely by the input's own focus/blur).+ expect(tsx).toContain("onClick={() => setQuery('')}")+ const clearButton = tsx.slice(tsx.indexOf('<button'), tsx.indexOf('</button>'))+ expect(clearButton).toContain('className="search-clear"')+ expect(clearButton).not.toMatch(/focus\(|engage\(/)+ expect(tsx).toContain("className={`search${query ? ' has-query' : ''}`}")+ })++ it('shows the clear button only when there is text', () => {+ expect(css).toMatch(/\.search-clear \{[^}]*visibility: hidden;[^}]*pointer-events: none;/)+ expect(css).toMatch(/\.search\.has-query \.search-clear \{[^}]*visibility: visible;[^}]*pointer-events: auto;/)+ })++ it('shows focus without a border: a lifted fill and a brighter icon', () => {+ expect(css).toMatch(/\.search input:focus \{\s*background: #222222;\s*\}/)+ // Borderless like the rest of the UI: no ring, no border on the field.+ expect(css).not.toMatch(/\.search input[^{]*\{[^}]*(box-shadow|border:\s*1px)/)+ expect(css).toMatch(/\.search:focus-within \.search-icon,\s*\.search\.has-query \.search-icon \{/)+ })++ it('is sized per dock from one rule set: 34px vertical, 30px horizontal', () => {+ expect(css).toMatch(/\.search \{[^}]*--search-h: 34px;/)+ expect(css).toMatch(/\.header-search-center \.search \{[^}]*--search-h: 30px;/)+ expect(css).toMatch(/\.search input \{[^}]*height: var\(--search-h\);[^}]*border: none;/)+ })+})