fix: 長按選字涵蓋引文/連結,並修正滑動換頁冷啟動未綁定 (#116 後續)#120
Merged
Merged
Conversation
- InlineStyles/DictionaryPage: 長按選字的 CSS 與 CONTENT_LOOKUP_LINK_SELECTOR
補上 .quote a、.link a,移除實際 DOM 不存在的 blockquote;兩處選擇器對齊。
修正 iOS 長按古籍引文/連結時仍跳原生選單、選不到字的問題。
- useSwipeNavigation: 改回傳 callback ref,在 <main> 掛載當下即綁定 listener,
修正冷啟動第一頁需先點一次滑動才生效的問題 (改在 Layout 以 ref={swipeRef} 掛載)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bestian
approved these changes
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
近端測試 PR #118/#119(issue #116 滑動換頁 + 長按選字)時,發現兩個小問題,這裡一起修正。核心功能本身都正常。
修正內容
1. iOS 長按選字漏掉「引文 / 連結」裡的字
InlineStyles.tsx關閉-webkit-touch-callout/ 開user-select: text的 CSS,以及DictionaryPage.tsx的CONTENT_LOOKUP_LINK_SELECTOR,原本只涵蓋.def / .definition / .example / .mandarin,漏掉了.quote a與.link a;而且兩處選擇器都用到blockquote,但實際 DOM 並不存在<blockquote>(引文是<div class="quote">、連結是<div class="link">)。結果:iOS 長按古籍引文、連結裡的字仍會跳出原生選單、選不到字——而引文正是使用者最想複製的內容。
修正:兩處選擇器補上
.quote a、.link a,移除無效的blockquote,並讓 CSS 與 JS 選擇器互相對齊(加註解交叉引用)。2. 滑動換頁在冷啟動第一頁未綁定 listener
useSwipeNavigation原本用useEffect+RefObject,但Layout在criticalCssReady && inlineStylesReady之前的 loading 分支不 render<main>,effect 先跑一次拿到null、之後<main>掛上時 deps 沒變不會重跑 —— 導致冷啟動第一頁要先點一次(任何 in-app 導航)滑動才生效。修正:改成回傳 callback ref,在
<main>掛載當下立即綁定 listener(Layout改用ref={swipeRef}),並用navigateRef保存最新navigate避免每次換頁重綁。手勢判定邏輯完全不變。測試
tsgo -b --noEmit/eslint通過。.quote a的user-select由auto變為text。備註
Android 在 history 最底層按返回會「停住、不退出 App」維持原設計(刻意避免誤觸退出);如需更貼近 Android 慣例可後續再以
moveTaskToBack/setEnabled(canGoBack())調整,本 PR 不動。🤖 Generated with Claude Code