fix(bpm-core-react): show only the latest member search results - #13
Open
coollugi wants to merge 4 commits into
Open
fix(bpm-core-react): show only the latest member search results#13coollugi wants to merge 4 commits into
coollugi wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DVBKX88XEgSHGrxzsL2Zjj
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DVBKX88XEgSHGrxzsL2Zjj
The manager-fallback picker built a "未知會員" sentinel for an empty memberId and never dropped it, so it appeared as a selectable phantom row before anyone had picked a fallback member; the same sentinel also won the merge dedupe over a genuine search hit once a real fallback id was set. Guard the empty id and merge the search results first so a real match always wins. Also guard `memberSearchResults` writes with a sequence ref: typing a narrower search text while a broader, slower request is still in flight could let the stale broad response overwrite the newer, correct one. `memberOptions` accumulation is unaffected since it only ever adds. Finally, clear `memberSearchResults` synchronously when any picker opens so the brief window between opening and the fetch landing never shows a different node's leftover results.
Add a spec for the manager-fallback picker: only the multi-select approver picker had a narrowing assertion, and the phantom-row defect lived in the fallback picker instead. Also add a deterministic regression test for a stale search response overwriting a newer one. It gates the mocked MemberOptions response so the test controls resolution order directly instead of racing real network timing, reproducing the exact race the sequencing fix guards against.
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.
簽核者欄位輸入關鍵字時,下拉清單不會收斂,畫面上永遠列出全部成員
重現
在流程設計器的簽核節點打開「簽核者」,輸入
chen後等待搜尋完成後端確實只回傳符合的成員,但下拉仍然列出目錄裡的每一個人
根因
handleSearchMembers把每次的搜尋結果併入memberOptions而不是取代它而三個 picker 都直接把
memberOptions當作options,且都帶disabledOptionsFilter(前端不再二次過濾)加上打開下拉時會先以空字串撈一次全部成員,於是畫面顯示的恆等於「目錄全集 ∪ 本次結果」
為什麼不是把 merge 改成取代
memberOptions同時承擔第二個職責:readMemberSelectOption用它把memberId還原成顯示名稱,畫布上其他節點的簽核者標籤、節點摘要文字都依賴它
直接改成只保留本次搜尋結果的話,其他節點的簽核者會全部退化成 fallback 標籤,比原本的問題更嚴重
修法
把兩個職責拆開
memberOptions維持累加,繼續作為 id 到顯示名稱的查詢來源memberSearchResults只保存最後一次回應mergeMemberOptions(<各自已選>, memberSearchResults),已選成員仍會留在清單中,不會因為搜尋而失去標籤同一份改動涵蓋簽核者、無主管時的改派人員、知會對象三處
驗證
pnpm typecheckpnpm lint(--skip-nx-cache)narrows the approver picker to the latest search result新測試透過
mockTemplateGraphQl的extraMembers選項加入第二位成員採用 opt-in 參數是為了不改變既有鍵盤操作測試所依賴的選項順序
normalizes legacy approval policy defaults before saving在main上本身就是失敗的原因是該測試的 fixture 中,edges 沒有
data欄位,而readEdgeSnapshot直接讀取edge.data.condition,導致設計器在載入時丟出
Cannot read properties of undefined,整個頁面無法渲染本 PR 沒有一併處理,供貴方參考