Skip to content

Commit 2bb09df

Browse files
Retsommclaude
andcommitted
fix(pwa): 修正 iOS 工具列按鈕需點兩下才反應的問題
使用 onTouchEnd + preventDefault() 讓按鈕在 touchEnd 立即觸發, 繞過 iOS Safari 在 epub iframe 有焦點時「第一次觸控消化焦點」的行為。 同時加入 touch-action: manipulation 移除 300ms 雙擊延遲。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 39816ff commit 2bb09df

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

pwa/src/components/Reader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,9 @@ const Reader = ({ bookPath, bookId, bookRecord, getCoverDataUrl, onBack, darkMod
16111611
fontFamily: '"JetBrains Mono", ui-monospace, monospace', letterSpacing: '0.06em',
16121612
borderBottom: `2px solid ${mobilePanelTab === key ? 'oklch(0.62 0.14 40)' : 'transparent'}`,
16131613
color: mobilePanelTab === key ? 'oklch(0.62 0.14 40)' : (darkMode ? '#7a706a' : '#9a8f80'),
1614+
touchAction: 'manipulation',
16141615
}}
1616+
onTouchEnd={(e) => { e.preventDefault(); setMobilePanelTab(key) }}
16151617
onClick={() => setMobilePanelTab(key)}
16161618
>
16171619
{label}

pwa/src/components/Toolbar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ const Toolbar = ({
127127
color: isActive ? accentCol : ink3Col,
128128
background: isActive ? accentBg : 'transparent',
129129
display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0,
130+
touchAction: 'manipulation',
130131
...extraStyle,
131132
}}
132133
onMouseEnter={(e) => { if (!isActive) e.currentTarget.style.background = hoverBg }}
133134
onMouseLeave={(e) => { e.currentTarget.style.background = isActive ? accentBg : 'transparent' }}
135+
onTouchEnd={(e) => { e.preventDefault(); onClick() }}
134136
onClick={onClick}
135137
aria-label={ariaLabel}
136138
title={ariaLabel}

0 commit comments

Comments
 (0)