Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done #768

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

done #768

wants to merge 1 commit into from

Conversation

bhoriunov
Copy link

DEMO LINK
btw this was too hard for me 😿

Copy link

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


Thank you for your hard work on this pull request! 😊 While your code is mostly well-structured and meets many of the task requirements, there are a couple of critical issues that need to be addressed before we can approve it:

  1. Filter on Spaces: The current implementation calls the filterSuggestions function even when the input is just spaces. This does not align with the task requirements, which specify that the filter should not be triggered by spaces alone. Please update the logic to handle this case.

  2. Key Generation: Ensure that person.slug is a unique and stable identifier for each suggestion. If slug is not guaranteed to be unique, it could lead to performance issues and bugs in React. Consider using a different unique identifier if necessary.

  3. JSX Syntax Error: There is a syntax error in your JSX expression. The ternary operator should be wrapped in curly braces to be evaluated correctly. Please fix this to ensure the component renders as expected.

Once these issues are resolved, your code will be in great shape! Keep up the great work, and don't hesitate to reach out if you have any questions or need further assistance. 🚀

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

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

src/App.tsx Show resolved Hide resolved
{suggestions.length > 0 ? (
suggestions.map(person => (
<div
key={person.slug}

Choose a reason for hiding this comment

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

Ensure that person.slug is a unique identifier for each Person. Using a non-unique key can lead to performance issues and bugs in React. If slug is not guaranteed to be unique, consider using a different unique identifier.

Copy link
Author

Choose a reason for hiding this comment

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

?

Copy link

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

Great job on implementing the main functionality of your components! 🎉 Your code meets most of the task requirements, and it's clear you've put a lot of effort into it. Here are a few points to consider for improvement:

  1. Filter on Spaces: Ensure that the filter function is not called when the input consists only of spaces. This will enhance the performance and user experience.

  2. Key Generation: Verify that person.slug is a stable and unique identifier to prevent potential issues with key generation during rendering.

  3. Naming Conventions: Review your method names to align with recommended naming conventions for better code clarity.

  4. Conditional Rendering: Use optional chaining or explicit checks when accessing properties of selectedPerson to avoid runtime errors.

  5. Function Responsibilities: Consider refactoring the handleInputChange function to keep it focused on its primary responsibility, and move unrelated logic elsewhere.

These improvements will not only help you comply with the task requirements but also enhance the overall quality of your code. Keep up the great work, and use this feedback to continue growing your skills! 🚀

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

Comment on lines +19 to +21
{selectedPerson
? `${selectedPerson.name} (${selectedPerson.born} - ${selectedPerson.died})`
: 'No selected person'}

Choose a reason for hiding this comment

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

The conditional rendering of selectedPerson is correct, but ensure that selectedPerson is not null before accessing its properties. The current implementation assumes selectedPerson is not null when accessing name, born, and died. Consider using optional chaining or a more explicit check to avoid potential runtime errors.

Comment on lines +40 to +43
if (selectedPerson) {
setSelectedPerson(null);
onSelected(null);
}

Choose a reason for hiding this comment

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

The check for selectedPerson before setting it to null and calling onSelected(null) is a good practice to avoid unnecessary state updates. However, consider moving this logic outside of the handleInputChange function if it's not directly related to input changes, to keep the function focused on its primary responsibility.

Comment on lines +55 to +58
if (!inputValue) {
setSuggestions(people);
setIsDropDownActive(true);
}

Choose a reason for hiding this comment

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

The handleInputFocus function sets suggestions to all people when the input is focused and empty. This is a good approach to show all options initially, but ensure that this behavior aligns with the desired user experience. If not, consider adjusting the logic to better fit the requirements.

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Almost done!
To improve:
You need to hide list of people when input is unfocused
image

Comment on lines +19 to +21
{selectedPerson
? `${selectedPerson.name} (${selectedPerson.born} - ${selectedPerson.died})`
: 'No selected person'}

Choose a reason for hiding this comment

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

Move this logic to the helper variable and use it here

};

return (
<div className={`dropdown ${isDropDownActive ? 'is-active' : ''}`}>

Choose a reason for hiding this comment

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

Use the classnames library for add classes with condition

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.

3 participants