Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there are a couple of critical requirement mismatches that will break the expected behavior and tests.
Critical issues that must be fixed:
- In
src/components/Autocomplete.tsx, the change handler currently always schedulessetNormalizedQuery(event.target.value)(around line 33), even when the input is only spaces. This violates the requirement to not run filtering for spaces-only input [CHECKLIST ITEM #1]. You should trim the value inside the timeout and, ifvalue.trim() === '', treat it as an empty input (e.g. setnormalizedQueryto''and avoid running the filter), and optionally skip updating when the value hasn’t actually changed. - In
src/App.tsx, the prop passed toAutocompleteis namedonSelect, but the task explicitly requires passing the selected person through anonSelectedcallback. Because of this mismatch, the Autocomplete component cannot call back correctly to set or clear the selected person (including callingonSelected(null)when the input changes), breaking the specified contract. Rename the prop toonSelectedand update the Autocomplete component to expect and invokeonSelected.
Once you address the spaces-only handling and align the callback prop name with the requirement, the implementation should satisfy the critical functional expectations. You’ve already covered most of the core behavior (debounce, selection updates, title rendering), so these focused fixes will bring the solution in line with the task. Keep going — you’re very close to a fully correct implementation.
✨ 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
| const handleQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
| setQuery(event.target.value); | ||
|
|
||
| window.clearTimeout(timerId.current); | ||
|
|
||
| if (selectedPerson && event.target.value !== selectedPerson.name) { | ||
| onSelect(null); | ||
| } | ||
|
|
||
| timerId.current = window.setTimeout(() => { | ||
| setNormalizedQuery(event.target.value); | ||
| }, delay); | ||
| }; | ||
|
|
||
| const filteredPeople = useMemo(() => { | ||
| return people.filter(person => person.name.includes(normalizedQuery)); | ||
| }, [normalizedQuery, people]); |
There was a problem hiding this comment.
This violates checklist item #1: "- make sure that filter won't be called if user enred spaces only;"
Currently you always schedule setNormalizedQuery(event.target.value) (line 33) even when the value is spaces-only. As a result the memoized filter (line 38) runs with a spaces-only string and returns no matches instead of treating it like an empty input. Consider trimming the value before scheduling the update and ignoring spaces-only input. Example approach: capture const value = event.target.value; then in the timeout use const trimmed = value.trim(); if (trimmed === '') { setNormalizedQuery(''); } else if (value !== normalizedQuery) { setNormalizedQuery(value); } — this avoids running the filter for spaces-only and also avoids updating state when the normalized value hasn't changed.
| </div> | ||
| <Autocomplete | ||
| people={peopleFromServer} | ||
| onSelect={handleSelectPerson} |
There was a problem hiding this comment.
The task description requires that the selected person be passed to an onSelected callback passed via props. Here the prop is named onSelect so the Autocomplete component will not receive the expected onSelected callback. Rename the prop to onSelected (and make the Autocomplete expect onSelected) so the component API matches the exact requirement.
| const { name, born, died } = peopleFromServer[0]; | ||
| const [selectedPerson, setSelectedPerson] = useState<Person | null>(null); | ||
|
|
||
| const handleSelectPerson = (person: Person | null) => { |
There was a problem hiding this comment.
Because the callback prop is misnamed, the Autocomplete won't be able to call back to clear the selected person when the input value changes. Ensure the prop name is corrected so that the App can receive onSelected(null) to update the title to No selected person when the input changes.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the current Autocomplete behavior still violates a critical checklist requirement around spaces-only input. Specifically, in src/components/Autocomplete.tsx, you always schedule setNormalizedQuery(event.target.value) (around line 33), so when the user types only spaces, the debounced filter (around line 38) runs with a spaces-only string and returns no matches instead of treating it as an empty query. This directly conflicts with the checklist requirement that the filter must not be run for spaces-only input [CHECKLIST ITEM #1]. To fix this, capture the raw value first (e.g. const value = event.target.value;), then in the timeout compute const trimmed = value.trim(); and either set normalizedQuery to '' when trimmed === '', or skip updating/filtering for spaces-only input; also consider skipping setNormalizedQuery when the value is effectively unchanged to avoid unnecessary work. Once you adjust the input handling so that spaces-only behaves like an empty input and does not trigger filtering, the component will align with the task expectations. Overall the rest of the behavior looks solid, and with this correction your solution should be in good shape.
✨ 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
| const handleQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
| setQuery(event.target.value); | ||
|
|
||
| window.clearTimeout(timerId.current); | ||
|
|
||
| if (selectedPerson && event.target.value !== selectedPerson.name) { | ||
| onSelect(null); | ||
| } | ||
|
|
||
| timerId.current = window.setTimeout(() => { | ||
| setNormalizedQuery(event.target.value); | ||
| }, delay); | ||
| }; | ||
|
|
||
| const filteredPeople = useMemo(() => { | ||
| return people.filter(person => person.name.includes(normalizedQuery)); | ||
| }, [normalizedQuery, people]); |
There was a problem hiding this comment.
This violates checklist item #1: "- make sure that filter won't be called if user enred spaces only;"
Currently you always schedule setNormalizedQuery(event.target.value) (line 33) even when the value is spaces-only. As a result the memoized filter (line 38) runs with a spaces-only string and returns no matches instead of treating it like an empty input. Consider trimming the value before scheduling the update and ignoring spaces-only input. Example approach: capture const value = event.target.value; then in the timeout use const trimmed = value.trim(); if (trimmed === '') { setNormalizedQuery(''); } else if (value !== normalizedQuery) { setNormalizedQuery(value); } — this avoids running the filter for spaces-only and also avoids updating state when the normalized value hasn't changed.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because, while the core autocomplete behavior is implemented correctly (debounce, Bulma dropdown, full list on focus, correct selection handling, and the No matching suggestions message), there is one critical issue that can break the tests. The task and tests expect specific data-qa attributes, but your components currently use data-cy on the input, the suggestions list, each suggestion item, and the "no suggestions" message in src/components/Autocomplete.tsx and the related usage in src/App.tsx, so automated checks that look for data-qa will not find the elements they need. To fix this, replace each data-cy="..." with the corresponding data-qa="..." value that the task specifies (e.g. on the text input, the container for the suggestions, each suggestion row, and the no-results label), and ensure the attribute values exactly match the expected names. As a minor improvement, you can avoid unnecessary state updates by only calling setNormalizedQuery(trimmedValue) inside your debounced handler when trimmedValue is actually different from the current normalized query (using a functional updater or a comparison against the latest state). Another optional enhancement is to make the filtering case-insensitive by lowercasing both the query and person.name before calling includes, which will feel more natural to users. Once you align the test attributes, your solution should fully satisfy both the functional requirements and the automated testing setup, and the rest of your implementation looks solid and thoughtful.
✨ 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
Anton-Kuchmasov
left a comment
There was a problem hiding this comment.
Good job!
Check out comments - they might be helpful
| }; | ||
|
|
||
| const filteredPeople = useMemo(() => { | ||
| return people.filter(person => person.name.includes(normalizedQuery)); |
| {focused && ( | ||
| <div className="dropdown-menu" role="menu" data-cy="suggestions-list"> | ||
| <div className="dropdown-content"> | ||
| {filteredPeople.length !== 0 ? ( |
There was a problem hiding this comment.
| {filteredPeople.length !== 0 ? ( | |
| {!!filteredPeople.length ? ( |

DEMO LINK