Skip to content

solution - #1269

Open
smialeknicole wants to merge 7 commits into
mate-academy:masterfrom
smialeknicole:develop
Open

smialeknicole wants to merge 7 commits into
mate-academy:masterfrom
smialeknicole:develop

Conversation

@smialeknicole

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Rate AI review example ↩

  2. Re-request AI review example ↩

  3. Add AI review comments example ↩

Comment thread src/App.tsx Outdated
const { name, born, died } = peopleFromServer[0];
const [selectedPerson, setSelectedPerson] = useState<Person | null>(null);

const onSelected = (person: Person | null) => setSelectedPerson(person);

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 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.

Comment thread src/Autocomplete.tsx
};

useEffect(() => {
const timer = setTimeout(() => {

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 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.

Comment thread src/Autocomplete.tsx
Comment on lines +29 to +30
peopleFromServer.filter(person =>
person.name.toLowerCase().includes(personName.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 filter runs even when the input contains only spaces, contrary to checklist item 1. Check for whitespace-only input before calling filter.

Comment thread src/Autocomplete.tsx Outdated
<div
className="dropdown-item"
data-cy="suggestion-item"
key={index}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Rate AI review example ↩

  2. Re-request AI review example ↩

  3. Add AI review comments example ↩

Comment thread src/App.tsx
return (
<div className="container">
<main className="section is-flex is-flex-direction-column">
<h1 className="title" data-cy="title">

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 uses data-cy, but the task requires preserving the data-qa attributes for tests. Use the required data-qa selector here.

Comment thread src/Autocomplete.tsx
Comment on lines +54 to +92
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Rate AI review example ↩

Comment thread src/App.tsx
return (
<div className="container">
<main className="section is-flex is-flex-direction-column">
<h1 className="title" data-cy="title">

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 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.

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