Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
This is a solid implementation, and you've done a great job meeting most of the requirements. The component is well-structured and the debouncing logic is correct. However, I'm requesting a small change to the filtering logic in src/components/Auto.tsx. Currently, the filter is triggered even if the user enters only spaces, which goes against the requirements [CHECKLIST ITEM #1]. To resolve this, please ensure you trim() the input value and only perform the filtering if the resulting string is not empty. This will make the component's behavior more robust and align with the task's checklist. Keep up the great work!
✨ 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
src/components/Auto.tsx
Outdated
| if (inputValue === '') { | ||
| setSuggestions(data); | ||
| } else { | ||
| const filtered = data.filter(person => | ||
| person.name.toLowerCase().includes(inputValue.toLowerCase()), | ||
| ); | ||
|
|
||
| setSuggestions(filtered); | ||
| } |
There was a problem hiding this comment.
This filtering logic doesn't account for inputs that contain only whitespace. This violates checklist item #1: 'make sure that filter won't be called if user enred spaces only;'.
Additionally, the inputValue is not trimmed before being used for filtering, which means that leading or trailing spaces will affect the search results (e.g., searching for " Ada " instead of "Ada").
You should trim the inputValue and only proceed with filtering if the result is not an empty string.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great job on the progress so far! You've correctly implemented the debouncing and state management. However, I'm requesting changes for a couple of issues that affect the core functionality.
- Incorrect Filtering with Whitespace: The filter logic currently uses the raw
inputValue, which includes spaces. This means a search for" Luke "won't find "Luke Skywalker". Please use thetrimmedValuefor the search. Also, an input containing only spaces incorrectly shows all suggestions instead of none, which violates a requirement [CHECKLIST ITEM #1]. - Dropdown Opens on Page Load: The suggestions dropdown appears automatically on the initial render without any user interaction. The requirement states that it should only open when the input is focused. The
onFocushandler already takes care of this, so the effect causing it to open on load needs to be adjusted.
Once these are fixed, your component will be perfect. Keep up the great work!
✨ 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
src/components/Auto.tsx
Outdated
| setSuggestions(data); | ||
| } else { | ||
| const filtered = data.filter(person => | ||
| person.name.toLowerCase().includes(inputValue.toLowerCase()), |
There was a problem hiding this comment.
The filter logic here uses inputValue, which includes leading/trailing whitespace. This will likely cause searches to fail (e.g., searching for " Luke " won't find "Luke Skywalker"). You should use trimmedValue for the search, which you've already calculated on line 24.
src/components/Auto.tsx
Outdated
| setSuggestions(filtered); | ||
| } | ||
|
|
||
| setDropdownActive(true); |
There was a problem hiding this comment.
Calling setDropdownActive(true) here causes the dropdown to open on the initial render without any user interaction. The requirement states that the list should appear "when input is focused". The onFocus handler already opens the dropdown, so this line may be unnecessary.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving this solution as an educational override to help you progress, but there is one key requirement that still needs to be addressed.
Great job fixing the previous issues with debouncing and whitespace handling! The component is much more robust now. The main issue remaining is that the suggestions list doesn't appear when the input is focused but empty. The current logic hides the dropdown when the input value is empty, which prevents the list of all people from showing up as required. This is also why the automated tests are failing—they can't find the dropdown menu to interact with.
To fix this, consider managing the dropdown's visibility with a dedicated state variable (e.g., isDropdownOpen). You can set this state to true on focus and use it to conditionally add the is-active class to the Bulma dropdown container. This will give you more direct control over when the dropdown appears.
Keep up the excellent work!
✨ 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
src/components/Auto.tsx
Outdated
| if (trimmedValue === '') { | ||
| // якщо інпут порожній або тільки пробіли — не показуємо підказок | ||
| setSuggestions([]); | ||
| setDropdownActive(false); // закриваємо dropdown |
There was a problem hiding this comment.
This logic hides the dropdown when the input becomes empty. This causes an issue when a user types something and then clears the input field. Even if the input is still focused, the suggestion list disappears. The expected behavior is for the list to show all people again, as per the requirement for an empty, focused input.
src/components/Auto.tsx
Outdated
| if (trimmedValue !== '') { | ||
| setDropdownActive(true); | ||
| setSuggestions( | ||
| data.filter(person => | ||
| person.name.toLowerCase().includes(trimmedValue.toLowerCase()), | ||
| ), | ||
| ); | ||
| } |
There was a problem hiding this comment.
This condition prevents suggestions from appearing when the input is focused while empty. According to the requirements, the component should 'show the list of all people when input is focused but empty'. This logic needs to be adjusted to handle the case where trimmedValue is empty and show all suggestions from the data prop.
etojeDenys
left a comment
There was a problem hiding this comment.
demo link does not work. please fix it and re-request the review. also, make sure you pass all the tests
Anton-Kuchmasov
left a comment
There was a problem hiding this comment.
DEMO link is not fixed yet, please run npm run deploy
[DEMO LINK] https://24O07.github.io/react_autocomplete/