Repository navigation
Conversation
Persist favorite math template ids in localStorage (max 10) behind a shared store and a useFavoriteMathTemplates hook. Stored data is sanitized on read, rejected writes leave state and storage untouched, and the list stays in sync across tabs via the storage event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show the saved favorite templates as the first math category, insert them on click, and open on it by default when the list is not empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Right-clicking a math template, or pressing the context menu key or Shift+F10 on it, opens an accessible menu to add it to favorites. Success is announced with a toast; reaching the limit or adding a duplicate shows an alert dialog, and focus returns to the template. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A new "Edit favorites" toolbar button opens a modal that edits a draft of the favorites list with move up, move down and remove buttons; it is saved only on Done. Changes are announced inside the dialog, the success toast waits until the dialog has closed, and an empty list shows how to add favorites instead. The toolbar now wraps on narrow screens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the minimum width and inner padding so a single item reads as one dark label with even padding, matching the design. The item highlights on hover and keyboard focus instead of on any focus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove comments that restate the code or a test name, and rewrite the rest in plain, active sentences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pressing Done without any change saved the list the modal opened with, which silently reverted changes another tab made in the meantime. Done now just closes the modal when the draft still matches the list at opening, and skips the "saved" toast because nothing was saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamliaoo
marked this pull request as ready for review
November 6, 2026 15:22
This branch has not been deployed
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.
背景描述 (Why)
編輯數學內容時,常在特定單元反覆使用少數幾個模版,例如幾何單元的弧、角、平行、垂直,多項式單元的分數和根號。目前每次都要在 14 個分類、141 個模版裡找,用鍵盤或螢幕閱讀器操作的人更費力。這個 PR 讓使用者把常用模版收進「常用符號」分類,之後點一下就能插入。
需求來自常用快捷功能的 PRD、EDD 和 Figma 設計稿。三者衝突的兩處依設計稿實作:
實作方法 (How)
資料層
access8math.favoriteMathTemplateIds。畫面需要時再用mathTabList建出的mathTemplateIndex查回完整模版。模版物件裡有 React 元件,無法序列化,只存 id 也不會留下過期的複本。createStore,元件透過以useSyncExternalStore實作的useFavoriteMathTemplates訂閱。EDD 原本建議把狀態放在EditIconsTab裡,但設計稿把「編輯常用」放在首頁工具列,兩邊必須共用同一份資料。storage事件,讓多個分頁的列表保持同步。介面
EditIconsTab在數學分類最前面加上「常用符號」分頁。列表不是空的時候預設開這個分頁,否則開「常見」。ContextMenu核心元件照 WAI-ARIA menu pattern 實作,支援右鍵、快顯鍵和 Shift+F10。選取項目時先把焦點還給模版按鈕再執行,之後 dialog 關閉時焦點才回得去。AlertModal負責上限、重複、列表為空三種提示,role 是alertdialog。EditFavoritesModal在草稿上編輯,按「完成」才呼叫saveFavorites。首頁每次開啟它都換一個key,讓草稿從已儲存的列表重新開始。無障礙
aria-disabled,移到頂端或底部時按鈕不會失焦。BasicModal新增可選的initialFocus和afterLeave,既有呼叫端行為不變。實際變更
src/lib/favorite-math-templates/,包含 store、hook 和模版 indexEditIconsTab加上常用符號分類、右鍵選單,以及加入後的 toast 和 dialogContextMenu與AlertModalEditFavoritesModal,首頁工具列加上「編輯常用」按鈕BasicModal新增可選 propinitialFocus與afterLeavetabs.json、home.json,並新增edit-favorites-modal.jsonsetupTests.js加上ResizeObserverstub,讓 Headless UI Dialog 能在 jsdom 裡測試截圖或錄影參考
待補:右鍵選單、上限與重複 dialog、編輯 modal、完整操作錄影
測試驗證
npm run lint、npm run format:check、npm run build通過?locale=en確認英文介面文案補充說明
相關連結