Skip to content

fix(ui): add type to useEffect dependency in DocumentTypeChip#979

Closed
tysoncung wants to merge 1 commit intoMODSetter:mainfrom
tysoncung:fix/946-useeffect-dependency-document-type-chip
Closed

fix(ui): add type to useEffect dependency in DocumentTypeChip#979
tysoncung wants to merge 1 commit intoMODSetter:mainfrom
tysoncung:fix/946-useeffect-dependency-document-type-chip

Conversation

@tysoncung
Copy link

@tysoncung tysoncung commented Mar 25, 2026

Problem

The DocumentTypeChip component checks if the label text is truncated using a useEffect with an empty dependency array []. If the type prop changes (which changes the label text), the truncation state won't update until a window resize event fires.

Solution

Add the type prop to the useEffect dependency array so the truncation check re-runs whenever the document type (and thus the label) changes.

Changes

  • surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentTypeIcon.tsx:
    • Changed useEffect(..., []) to useEffect(..., [type])

Closes #946

High-level PR Summary

This PR fixes a bug in the DocumentTypeChip component where the text truncation state wouldn't update when the type prop changes. The fix adds type to the useEffect dependency array so the truncation check re-runs whenever the document type (and thus the label text) changes, ensuring the truncation detection stays accurate.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentTypeIcon.tsx

Need help? Join our Discord

Analyze latest changes

…ter#946)

The truncation check useEffect had an empty dependency array, so it
only ran on mount. If the type prop changed (changing the label text),
the truncation state would not update until a window resize event.

Add type to the dependency array so the check re-runs when the label
changes.

Closes MODSetter#946
@vercel
Copy link

vercel bot commented Mar 25, 2026

Someone is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on a474c46..e8ac02c

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (1)

surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentTypeIcon.tsx

@MODSetter
Copy link
Owner

@tysoncung, please raise this PR on the "dev" branch.

@MODSetter MODSetter closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix useEffect dependency in DocumentTypeChip truncation check

2 participants