⚡ Bolt: Optimize Autocomplete filtering by removing redundant manual state tracking - #70
Conversation
- Replaces redundant manual local `searchTerm` filtering inside parent components with the native `filterSelectedOptions` prop on `VarietySelect`, `FarmerSelect`, and `CertificationSelect`. - Prevents expensive parent re-renders on every keystroke by removing the state tracking. - Updates `onChange` mappings to properly preserve referential equality, allowing MUI's internal selected option filtering to work natively and correctly. Co-authored-by: AntonioCardenas <11583391+AntonioCardenas@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
✅ Deploy Preview for heartfelt-swan-19c038 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
💡 What
Refactored
VarietySelect,FarmerSelect, andCertificationSelectcomponents to remove unnecessary local React state that manually tracked user keystrokes (searchTerm). We now delegate filtering to Material-UI's native, highly-optimizedAutocompleteinternal logic by utilizing thefilterSelectedOptionsprop.Additionally, updated the
onChangelogic to pass referentially intact object selections rather than mapping to newly minted copies.🎯 Why
Previously, the parent component triggered a full re-render on every single keystroke to manually compute
filteredVarietiesandfilteredFarmersfrom large arrays. Furthermore, the previous logic inonChangemapped selected objects to newly instantiated object references, which silently brokeAutocomplete's built-in referential equality checks. By stripping out the redundant state and correcting the referential passing, the component is significantly faster.📊 Impact
Eliminates hundreds of unnecessary, blocking component re-renders per form session by dropping keystroke state tracking entirely.
🔬 Measurement
/createor any module utilizing the select dropdowns (e.g. Varieties or Farmers).filterSelectedOptionsbehavior without the parent having to filter the list manually.PR created automatically by Jules for task 923842345858017487 started by @AntonioCardenas