Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken relation picker in Kanban #8377

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

ijreilly
Copy link
Collaborator

@ijreilly ijreilly commented Nov 6, 2024

Fixes #8233

Typing a search input was triggering a re-render of the whole RecordBoardCard, resetting the search input to its initial value, an empty string, making it impossible to actually type anything.
useRelationPicker had (legacy?) useless dependencies to recoil states that caused the rerenders.

@ijreilly ijreilly requested a review from lucasbordeau November 6, 2024 18:27
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR fixes re-rendering issues in the Kanban view's relation picker by optimizing state management and component structure to allow proper search input functionality.

  • Moved search filter initialization to new SearchPickerInitialValueEffect component to prevent unwanted re-renders of RecordBoardCard
  • Simplified useRelationPicker hook in /hooks/useRelationPicker.ts by removing unnecessary Recoil state dependencies
  • Added debug logging in /hooks/useEntitySelectSearch.ts to track search filter changes
  • Modified RelationPicker component to use the new effect-based initialization pattern

4 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +20 to +22
useEffect(() => {
setRelationPickerSearchFilter(initialValueForSearchFilter ?? '');
}, [initialValueForSearchFilter, setRelationPickerSearchFilter]);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This effect will run on every relationPickerScopeId change since getRelationPickerScopedStates is called in render. Consider memoizing the state or adding relationPickerScopeId to effect deps.

setRelationPickerSearchFilter(initialValueForSearchFilter ?? '');
}, [initialValueForSearchFilter, setRelationPickerSearchFilter]);

return <></>;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Empty fragment is unnecessary since this is an effect-only component. Consider returning null instead.

relationPickerScopeId: string;
}) => {
const { relationPickerSearchFilterState } = getRelationPickerScopedStates({
relationPickerScopeId: relationPickerScopeId,
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Redundant object property name. Can be shortened to just relationPickerScopeId

@@ -26,6 +26,7 @@ export const useEntitySelectSearch = ({
const handleSearchFilterChange = (
event: React.ChangeEvent<HTMLInputElement>,
) => {
console.log('set search filter', event.currentTarget.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove debug console.log before merging to production

Comment on lines +17 to +20
const { relationPickerSearchFilterState, relationPickerPreselectedIdState } =
useRelationPickerScopedStates({
relationPickerScopedId: scopeId,
});

This comment was marked as resolved.

@lucasbordeau lucasbordeau enabled auto-merge (squash) November 7, 2024 13:49
@lucasbordeau lucasbordeau merged commit 60349d0 into main Nov 7, 2024
19 checks passed
@lucasbordeau lucasbordeau deleted the fix-relation-picker-broken-kanban branch November 7, 2024 13:55
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.

Relation picker is broken on kanban
2 participants