Skip to content

Add solution#1130

Open
Yar14k wants to merge 3 commits intomate-academy:masterfrom
Yar14k:developer
Open

Add solution#1130
Yar14k wants to merge 3 commits intomate-academy:masterfrom
Yar14k:developer

Conversation

@Yar14k
Copy link
Copy Markdown

@Yar14k Yar14k commented Mar 1, 2026

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

This requires a few changes before it can be approved. You've done a great job implementing the core functionality, like debouncing the input and displaying suggestions. However, there are a few key requirements that need to be addressed.

In src/App.tsx, the onSelected prop is not being called when a user selects a person. This is a core part of the component's functionality.

Additionally, the filtering logic has a couple of issues:

  1. It runs on every render, even when the input text hasn't changed. This should be memoized, for example, with the useMemo hook.
  2. The filter is still triggered if the user only types spaces, which should be prevented [CHECKLIST ITEM #1]. You can fix this by trimming the input value before filtering.

Please address these points, and your solution will be ready for approval!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/App.tsx Outdated
onSelected?: (person: Person) => void;
};

export const App: React.FC<AppProps> = ({ debounceDelay = 300 }) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The onSelected prop is defined in AppProps but is not being destructured and used. To meet the requirement to "pass the selected person to the onSelected callback passed via props", you need to get it from the props here and call it when a selection is made.

src/App.tsx Outdated
Comment on lines +26 to +28
const filteredPeople = peopleFromServer.filter(person => {
return person.name.toLowerCase().includes(debouncedValue.toLowerCase());
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This filtering logic has two issues:

  1. It runs on every component render, not only when debouncedValue changes. This violates the requirement: "don't run filtering again if the text has not changed".
  2. The filter is executed even if the user enters only spaces, which violates checklist item react_autocomplete #1: "make sure that filter won't be called if user enred spaces only".

Both issues can be resolved by wrapping this logic in a useMemo hook and checking if the trimmed debouncedValue is empty before filtering.

Comment on lines +82 to +86
onMouseDown={() => {
setInputValue(person.name);
setSelectedPerson(person);
setIsFocused(false);
}}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When a person is selected, you also need to call the onSelected prop (which should be destructured from the component's props) with the selected person.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great work on this update! You've successfully addressed all the feedback from the previous review, and the component is very close to being perfect.

I'm requesting one small change to fix a bug in the filtering logic. Currently, the search fails if the input has leading or trailing spaces (e.g., " Ada "). This is because you are using the original debouncedValue for the search comparison inside your useMemo hook in src/App.tsx.

To fix this, please ensure you use the trimmed value for the actual filtering, just as you do for the check to see if the input is empty. Once you've made that adjustment, this will be ready to merge!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/App.tsx Outdated
}

return peopleFromServer.filter(person => {
return person.name.toLowerCase().includes(debouncedValue.toLowerCase());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The filtering is being performed with debouncedValue, which might include leading or trailing spaces. To ensure correct matching, you should use the trimmedValue here for the search, just as you did for the check on line 32.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Excellent work on this pull request! I am approving your solution as you have successfully addressed the previous feedback, and the component now correctly handles search terms with leading or trailing whitespace. The code is clean, well-structured, and correctly implements the debouncing, filtering, and state management logic. The component now meets all functional and technical requirements perfectly. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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.

2 participants