Conversation
openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| const onPaneClick = useCallback(() => { | ||
| setIsDrawerOpen(false); | ||
| setTracedNodes([]); |
There was a problem hiding this comment.
🚨 Bug: onPaneClick passes arrays instead of Sets to store setters
In onPaneClick (LineageProvider.tsx), setTracedNodes([]) and setTracedColumns([]) pass empty arrays, but the Zustand store now expects Set<string> for both. All other call sites were properly updated to new Set(), but these two were missed.
This will cause a TypeScript compilation error, and if it somehow reaches runtime (e.g., via any casts), every call to .has() or .size on tracedColumns/tracedNodes throughout the codebase would crash.
Fix:
const onPaneClick = useCallback(() => {
setTracedNodes(new Set());
setTracedColumns(new Set());
setSelectedColumn('');
setActiveNode(undefined);
setSelectedNode(undefined);
}, []);Was this helpful? React with 👍 / 👎
|
|
||
| setIsEditMode: (isEditMode: boolean) => set({ isEditMode }), | ||
|
|
||
| toggleEditMode: () => { |
There was a problem hiding this comment.
⚠️ Bug: toggleEditMode doesn't clear local selectedEdge state
The old onLineageEditClick in LineageProvider explicitly called setSelectedEdge(undefined) (local state) to close the drawer when toggling edit mode. The new toggleEditMode in the Zustand store sets selectedEdge: undefined on the store's copy, but LineageProvider still manages selectedEdge as local React state (line 196: const [selectedEdge, setSelectedEdge] = useState<Edge>()). The store's setter and the provider's local setter are different.
This means when a user toggles edit mode while an edge drawer is open, the drawer won't close because the local selectedEdge is never cleared.
Fix: Either:
- Move
selectedEdgefully into the Zustand store and consume it from there in the provider, OR - Have the
CustomControlscomponent call a provider callback (like the oldonLineageEditClick) that clears local state alongside toggling the store's edit mode.
Was this helpful? React with 👍 / 👎
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
Describe your changes:
Fixes
I worked on ... because ...
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>Summary by Gitar
LineageProviderContext into newuseLineageStore.tsZustand store to prevent unnecessary re-rendersuseMapBasedNodesEdgeshook with Map-based state management for O(1) node/edge operations (add, remove, update)columnsHavingLineagefrom array toSetfor O(1) lookups and replaced array operations with Map-based lookupsEntityTypeIconandEntityFooterinReact.memoand optimizedcalculateHeightAndFlattenNodewith accumulator patternThis will update automatically on new commits.