Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,18 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
// ========================= Disabled =========================
const disabledCacheRef = React.useRef<Map<string, boolean>>(new Map());

// Clear cache if `leftMaxCount` changed
// Force update is needed since clearing cache alone doesn't trigger
// a recalculation of node disabled states
const [, setForceUpdate] = React.useState({});

// When leftMaxCount changes, we need to:
// 1. Clear the disabled state cache
// 2. Trigger a re-render to recalculate all node disabled states
// This ensures parent nodes are properly disabled when max count is reached
React.useEffect(() => {
if (leftMaxCount) {
disabledCacheRef.current.clear();
setForceUpdate({});
}
}, [leftMaxCount]);

Expand Down
Loading