Repository navigation
solution - #1269
solution#1269smialeknicole wants to merge 7 commits into
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The main autocomplete flow and selected-person display are in place, but several explicit requirements still need attention. In src/Autocomplete.tsx, skip filtering when the input is empty or whitespace-only, show all people immediately when an empty input is focused, and use a stable person identifier instead of the array index for suggestion keys. The rendered test attributes also use data-cy rather than the required data-qa; align them with the specified selectors. In src/App.tsx, rename the local selection event handler to follow the required handle... convention, keeping onSelected for the callback prop. These targeted updates will bring the implementation in line with the checklist.
✨ 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 { name, born, died } = peopleFromServer[0]; | ||
| const [selectedPerson, setSelectedPerson] = useState<Person | null>(null); | ||
|
|
||
| const onSelected = (person: Person | null) => setSelectedPerson(person); |
There was a problem hiding this comment.
This violates checklist item 4: “follow these naming conventions for methods.” The locally declared event handler should use the handle... naming convention; onSelected is better suited to the callback prop name.
| }; | ||
|
|
||
| useEffect(() => { | ||
| const timer = setTimeout(() => { |
There was a problem hiding this comment.
This effect also applies the debounce to the initial empty value, so focusing the input before that timer expires shows an empty list instead of all people. Show all people immediately when the empty input is focused; keep the debounce for typed queries.
| peopleFromServer.filter(person => | ||
| person.name.toLowerCase().includes(personName.toLowerCase()), |
There was a problem hiding this comment.
The filter runs even when the input contains only spaces, contrary to checklist item 1. Check for whitespace-only input before calling filter.
| <div | ||
| className="dropdown-item" | ||
| data-cy="suggestion-item" | ||
| key={index} |
There was a problem hiding this comment.
Using the array index as a key generates keys during rendering, which violates checklist item 3. Use a stable identifier from each person instead.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The autocomplete behavior and selected-person flow appear to meet the functional requirements, but the required test selectors are still data-cy rather than data-qa. In src/App.tsx, update the selected-person heading attribute; in src/Autocomplete.tsx, update the input, suggestion list, suggestion item, and no-results attributes to the required data-qa names. Tests that locate these elements by the specified attributes may otherwise fail. Once the selectors match the task requirements, the implementation 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
| return ( | ||
| <div className="container"> | ||
| <main className="section is-flex is-flex-direction-column"> | ||
| <h1 className="title" data-cy="title"> |
There was a problem hiding this comment.
This uses data-cy, but the task requires preserving the data-qa attributes for tests. Use the required data-qa selector here.
| data-cy="search-input" | ||
| value={personName} | ||
| onFocus={() => setIsActive(true)} | ||
| onBlur={() => setIsActive(false)} | ||
| onChange={event => { | ||
| setPersonName(event.target.value); | ||
| onSelected(null); | ||
| }} | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="dropdown-menu" role="menu" data-cy="suggestions-list"> | ||
| <div className="dropdown-content"> | ||
| {filteredPeople.map(suggestion => { | ||
| return ( | ||
| <div | ||
| className="dropdown-item" | ||
| data-cy="suggestion-item" | ||
| key={suggestion.slug} | ||
| onMouseDown={() => handleClick(suggestion)} | ||
| > | ||
| <p className="has-text-link">{suggestion.name}</p> | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {hasFiltered && filteredPeople.length === 0 && ( | ||
| <div | ||
| className=" | ||
| notification | ||
| is-danger | ||
| is-light | ||
| mt-3 | ||
| is-align-self-flex-start" | ||
| role="alert" | ||
| data-cy="no-suggestions-message" |
There was a problem hiding this comment.
These selectors use data-cy, but the task requires the data-qa attributes used by the tests. Update the input, list, item, and no-results attributes to the required data-qa names.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your autocomplete implementation handles the required filtering, debounce, selection, and data-qa selectors well. The selected-person heading in src/App.tsx still uses data-cy; change it to data-qa so tests can locate the heading as required. I am approving this as an educational override to help you progress while learning, while highlighting this selector fix for your next update.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| return ( | ||
| <div className="container"> | ||
| <main className="section is-flex is-flex-direction-column"> | ||
| <h1 className="title" data-cy="title"> |
There was a problem hiding this comment.
The heading still uses data-cy, but the required test selector is data-qa. Please update the attribute so tests can locate the selected-person heading.
No description provided.