Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 手机上搜索键盘标成搜索、控件长按不选字

longmeidao690455c78277
diff --git a/frontend/e2e/design-detail.test.ts b/frontend/e2e/design-detail.test.ts
index ab6655a11..cb03a31fe 100644
--- a/frontend/e2e/design-detail.test.ts
+++ b/frontend/e2e/design-detail.test.ts
@@ -472,6 +472,30 @@ describe('设计决定:关注详情、作品详情、播放器与侧栏', () =
}
});
+ it('手机上详情浮窗的按钮与标签长按不选字、点按不等双击判定;标题照常能选中复制', { timeout: 60_000 }, async () => {
+ const opened = await openItemPage(browser, `/item/${ITEM.plain}`, MOBILE);
+ try {
+ const page = opened.page;
+ await page.locator('#stage [data-detail-tag] [data-tag]').first().waitFor({ state: 'attached' });
+ const read = await page.evaluate(() => {
+ const controls = [...document.querySelectorAll<HTMLElement>('#stage button, #stage summary, #stage [role="button"]')];
+ const off = controls.flatMap((control) => {
+ const style = getComputedStyle(control);
+ return style.touchAction === 'manipulation' && style.userSelect === 'none'
+ ? [] : [`${control.outerHTML.slice(0, 80)} → ${style.touchAction} / ${style.userSelect}`];
+ });
+ return { count: controls.length, off,
+ title: getComputedStyle(document.querySelector('#stage [data-detail-title]')!).userSelect };
+ });
+ assert.ok(read.count > 5, `详情浮窗里只量到 ${read.count} 个控件`);
+ assert.deepEqual(read.off, []);
+ assert.notEqual(read.title, 'none', '标题是内容,不能跟着控件一起关掉选字');
+ assert.deepEqual(withoutPlayer(opened.problems), []);
+ } finally {
+ await opened.close();
+ }
+ });
+
it('播放器控件:40px 黑圆播放键、同一档黑的右侧胶囊与提示、钨丝色进度、页面字体;统计键与加载速度角标压在左上;报错是一张盖在统计上面的卡', { timeout: 60_000 }, async () => {
const opened = await openItemPage(browser, `/item/${ITEM.plain}`, DESKTOP);
try {
diff --git a/frontend/e2e/index-people.test.ts b/frontend/e2e/index-people.test.ts
index c53669feb..1e7a6a841 100644
--- a/frontend/e2e/index-people.test.ts
+++ b/frontend/e2e/index-people.test.ts
@@ -110,4 +110,13 @@ describe('本地与在线艺人共用名册布局', () => {
assert.deepEqual(opened.problems, []);
} finally { await opened.close() }
});
+ it('名册过滤框在手机上弹出的软键盘回车键标成「搜索」', { timeout: 60_000 }, async () => {
+ const opened = await visit(browser, '/performers', VIEWPORTS[1]);
+ try {
+ const input = opened.page.locator('#index [data-index-search] input');
+ await input.waitFor({ timeout: 15_000 });
+ assert.equal(await input.getAttribute('enterkeyhint'), 'search');
+ assert.deepEqual(opened.problems, []);
+ } finally { await opened.close() }
+ });
});
diff --git a/frontend/e2e/search.test.ts b/frontend/e2e/search.test.ts
index f3889e43d..85fac7e42 100644
--- a/frontend/e2e/search.test.ts
+++ b/frontend/e2e/search.test.ts
@@ -97,6 +97,15 @@ describe('顶栏搜索', () => {
}
});
+ it('软键盘的回车键标成「搜索」', { timeout: 60_000 }, async () => {
+ const opened = await openSearch(browser);
+ try {
+ assert.equal(await opened.page.locator('#q').getAttribute('enterkeyhint'), 'search');
+ } finally {
+ await opened.close();
+ }
+ });
+
it('上下键环绕着选;回车按选中的那一项搜,记进搜索记录,下拉栏收起', { timeout: 60_000 }, async () => {
const opened = await openSearch(browser);
try {
diff --git a/frontend/src/react/activity/resource-search.tsx b/frontend/src/react/activity/resource-search.tsx
index 0dcda6528..eccd0c20b 100644
--- a/frontend/src/react/activity/resource-search.tsx
+++ b/frontend/src/react/activity/resource-search.tsx
@@ -52,7 +52,7 @@ export function ResourceSearch({ initialCode, reason, choose }: {
return (
<section aria-label="资源搜索" aria-busy={Boolean(action.busy)} className="flex min-w-0 flex-col gap-4">
{reason ? <Help>版本目标:{reason}。可在下方调整搜索优先项;完整度与水印需要逐条复核。</Help> : null}
- <Input label="搜索资源" value={code} maxLength={80} placeholder="输入番号,按回车搜索"
+ <Input label="搜索资源" value={code} maxLength={80} placeholder="输入番号,按回车搜索" enterKeyHint="search"
leadingIcon={action.busy ? SearchSpinner : RiSearchLine}
isReadOnly={Boolean(action.busy)} aria-busy={Boolean(action.busy)} onChange={setCode} onKeyDown={(event) => {
if (event.key === 'Enter' && !event.nativeEvent.isComposing) { event.preventDefault(); search() }
diff --git a/frontend/src/react/follow-manage/add-feed.tsx b/frontend/src/react/follow-manage/add-feed.tsx
index 3bbe9c04d..477defe23 100644
--- a/frontend/src/react/follow-manage/add-feed.tsx
+++ b/frontend/src/react/follow-manage/add-feed.tsx
@@ -98,7 +98,7 @@ export function AddFeed({ readOnly, toast, onAdded }: AddFeedProps) {
<div className="flex flex-wrap items-end gap-2">
<div className="min-w-64 grow">
<Input aria-label="女优名" placeholder={PLACEHOLDER} value={name} leadingIcon={RiSearchLine}
- isDisabled={readOnly} onChange={setName} onKeyDown={onKeyDown} />
+ enterKeyHint="search" isDisabled={readOnly} onChange={setName} onKeyDown={onKeyDown} />
</div>
<Button variant="primary" disabled={readOnly || !name.trim()} {...busyProps(action.busy === 'lookup')}
onClick={search}>查找</Button>
diff --git a/frontend/src/react/follow-manage/add-source.tsx b/frontend/src/react/follow-manage/add-source.tsx
index 66e2364db..e80d5e7f3 100644
--- a/frontend/src/react/follow-manage/add-source.tsx
+++ b/frontend/src/react/follow-manage/add-source.tsx
@@ -360,7 +360,7 @@ export function AddSource({ data, credentials, readOnly, toast, openCredentials
if (!event.currentTarget.contains(next) && !menu.current?.contains(next)) setFocused(false);
}}>
<Input aria-label="来源链接、名字或 id" placeholder={PLACEHOLDER} value={line}
- leadingIcon={RiSearchLine} isDisabled={readOnly} onChange={setLine}
+ leadingIcon={RiSearchLine} enterKeyHint="search" isDisabled={readOnly} onChange={setLine}
onKeyDown={onKeyDown} />
{menuOpen ? (
<SuggestMenu field={field} menu={menu} options={options} active={active}
diff --git a/frontend/src/react/index/index-page.tsx b/frontend/src/react/index/index-page.tsx
index 1a94eaabe..d0e8b3fa2 100644
--- a/frontend/src/react/index/index-page.tsx
+++ b/frontend/src/react/index/index-page.tsx
@@ -98,7 +98,7 @@ function IndexSearch({ label, value, onQuery }: { label: string; value: string;
<div data-index-search="" className="ml-auto min-w-35 max-w-80 flex-1 max-board-narrow:order-1 max-board-narrow:basis-40"
onCompositionStart={() => { composing.current = true }}
onCompositionEnd={(event) => { composing.current = false; later((event.target as HTMLInputElement).value) }}>
- <TextField aria-label={label} value={text}
+ <TextField aria-label={label} value={text} enterKeyHint="search"
onChange={(next) => { setText(next); if (!composing.current) later(next) }}>
<InputBase type="search" leadingIcon={SearchGlyph} spellCheck={false} autoComplete="off"
onKeyDown={onKeyDown} />
diff --git a/frontend/src/react/settings-panel/number-setting.tsx b/frontend/src/react/settings-panel/number-setting.tsx
index 52691c772..e302b2c69 100644
--- a/frontend/src/react/settings-panel/number-setting.tsx
+++ b/frontend/src/react/settings-panel/number-setting.tsx
@@ -102,7 +102,7 @@ export function NumberSetting({ id, label, value, disabled = false, onApply }: {
: null}
<div data-number-fields="" hidden={optional && !on}>
<div data-number-control="">
- <input ref={input} type="number" className="geist-input" min={min} max={max} step={1}
+ <input ref={input} type="number" inputMode="numeric" className="geist-input" min={min} max={max} step={1}
value={draft} disabled={blocked} aria-label={label} aria-describedby={`${id}-error`}
onChange={(event) => {
setDraft(event.target.value);
diff --git a/frontend/src/ui-kit/markup.ts b/frontend/src/ui-kit/markup.ts
index b160626de..d90533d6e 100644
--- a/frontend/src/ui-kit/markup.ts
+++ b/frontend/src/ui-kit/markup.ts
@@ -107,7 +107,7 @@ export function searchInputHtml({label,id='',name='',value='',placeholder='',att
label?: string; id?: string; name?: string; value?: unknown; placeholder?: string; attrs?: string;
}={}):string{
const parts=[
- 'type="search"',
+ 'type="search" enterkeyhint="search"',
id?`id="${esc(id)}"`:'',
name?`name="${esc(name)}"`:'',
placeholder?`placeholder="${esc(placeholder)}"`:'',
diff --git a/web/css/01-base.css b/web/css/01-base.css
index e8bbf9144..f8fdca1eb 100644
--- a/web/css/01-base.css
+++ b/web/css/01-base.css
@@ -251,7 +251,10 @@ body{background:var(--page);color:var(--ink);
.mono{font-family:"Cascadia Mono",Consolas,ui-monospace,"Microsoft YaHei UI","PingFang SC",monospace;
font-variant-numeric:tabular-nums;font-size:var(--fs-xs)}
button,input,textarea{font:inherit;color:inherit}
-button,a,input,textarea,select,summary{touch-action:manipulation}
+button,a,input,textarea,select,summary,[role="button"]{touch-action:manipulation}
+/* 控件上的字不是内容:触屏长按按钮、标签 chip 或折叠标题时不选中字、不弹系统菜单。
+ 链接和输入框不在这里——标题、番号、路径要能长按复制。 */
+button,[role="button"],summary{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
/* React 子树的焦点环由 BoardUI 组件自己画(输入框画在外框上);`:where` 让特指度保持 0,1,0。 */
:where(:not(.peach-react *)):focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
diff --git a/web/dist/peach-entry.js b/web/dist/peach-entry.js
index edab32687..e49a88558 100644
--- a/web/dist/peach-entry.js
+++ b/web/dist/peach-entry.js
@@ -764,7 +764,7 @@ function rt(e = "加载中") {
}
function it({ label: e, id: t = "", name: r = "", value: i = "", placeholder: a = "", attrs: o = "" } = {}) {
let s = [
- "type=\"search\"",
+ "type=\"search\" enterkeyhint=\"search\"",
t ? `id="${m(t)}"` : "",
r ? `name="${m(r)}"` : "",
a ? `placeholder="${m(a)}"` : "",
diff --git a/web/dist/peach-react.js b/web/dist/peach-react.js
index 6f3512f3a..95aed248e 100644
--- a/web/dist/peach-react.js
+++ b/web/dist/peach-react.js
@@ -42413,6 +42413,7 @@ function Rge({ data: e, credentials: t, readOnly: n, toast: r, openCredentials:
placeholder: jge,
value: a,
leadingIcon: CT,
+ enterKeyHint: "search",
isDisabled: n,
onChange: o,
onKeyDown: te
@@ -44568,6 +44569,7 @@ function I_e({ readOnly: e, toast: t, onAdded: n }) {
placeholder: N_e,
value: r,
leadingIcon: CT,
+ enterKeyHint: "search",
isDisabled: e,
onChange: i,
onKeyDown: d
@@ -45812,6 +45814,7 @@ function eve({ initialCode: e, reason: t, choose: n }) {
value: r,
maxLength: 80,
placeholder: "输入番号,按回车搜索",
+ enterKeyHint: "search",
leadingIcon: _.busy ? Q_e : CT,
isReadOnly: !!_.busy,
"aria-busy": !!_.busy,
@@ -47154,6 +47157,7 @@ function Mve({ label: e, value: t, onQuery: n }) {
children: /* @__PURE__ */ (0, V.jsx)(qM, {
"aria-label": e,
value: r,
+ enterKeyHint: "search",
onChange: (e) => {
i(e), a.current || s(e);
},
@@ -52569,6 +52573,7 @@ function GR({ id: e, label: t, value: n, disabled: r = !1, onApply: i }) {
children: [/* @__PURE__ */ (0, V.jsx)("input", {
ref: v,
type: "number",
+ inputMode: "numeric",
className: "geist-input",
min: o,
max: s,
diff --git a/web/index.html b/web/index.html
index d84bcf4a0..adac0c9d3 100644
--- a/web/index.html
+++ b/web/index.html
@@ -221,7 +221,7 @@
<a class="brand" href="#" id="brandHome"><img class="mark" src="/peach-logo.png" alt=""><h1 class="disp">Peach</h1><span class="sub mono">蜜桃</span></a>
<button class="ib searchback" id="searchBack" title="退出搜索" aria-label="退出搜索"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-chevron-left"/></svg></button>
<div class="search"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-search"/></svg>
- <input id="q" name="q" type="search" placeholder="搜索馆藏" data-suggestion="" autocomplete="off" aria-label="搜索作品、女优、厂牌或标签">
+ <input id="q" name="q" type="search" enterkeyhint="search" placeholder="搜索馆藏" data-suggestion="" autocomplete="off" aria-label="搜索作品、女优、厂牌或标签">
<div class="searchmenu" id="searchMenu" data-search-menu hidden></div></div>
<button class="ib" id="searchBtn" title="搜索" aria-label="搜索"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-search"/></svg></button>
<button class="ib" id="immerseBtn" title="沉浸模式 · 随机连播" aria-label="进入沉浸模式"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-play"/></svg></button>