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

add solution #774

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add solution #774

wants to merge 2 commits into from

Conversation

lerika7
Copy link

@lerika7 lerika7 commented Nov 12, 2024

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 you've made a great effort, there are a few critical issues that need to be addressed to meet the core requirements of the task:

  1. Debounce Implementation: The code lacks debounce logic for the suggestions, which is a core requirement. This feature should be customizable via props with a default value of 300ms.

  2. Show All People on Focus: The list of all people should appear when the input is focused but empty. This functionality is currently missing.

  3. Filter Call on Spaces: The filter should not trigger if the user enters only spaces. This case needs explicit handling.

  4. Key Generation: Using person.name as a key might not be unique, which can lead to performance issues. Consider using a more unique identifier like an id.

  5. Naming Conventions: Ensure that method names follow the recommended naming conventions for better readability and maintainability.

Please address these issues to ensure the functionality aligns with the task requirements. Once these changes are made, your code will be in great shape! Keep up the good work, and don't hesitate to reach out if you 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.

import './App.scss';
import { peopleFromServer } from './data/people';
import { DropdownMenu } from './components/DropdownMenu';

Choose a reason for hiding this comment

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

Ensure that the DropdownMenu component is correctly implemented and imported. Verify that it accepts the people and onSelected props as expected. If the DropdownMenu component is not implemented correctly, it might cause runtime errors.

<div
className="dropdown-item"
data-cy="suggestion-item"
key={person.name}

Choose a reason for hiding this comment

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

Consider using a more unique identifier for the key prop, such as an id if available, instead of person.name. Using a non-unique key can lead to performance issues and unexpected behavior in React.

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 addressing several issues from the previous review! 🎉 Your efforts in improving the App and DropdownMenu components are evident. However, there are still some critical points that need attention to fully meet the task requirements:

  1. Debounce Implementation: The debounce logic is currently set with a fixed delay of 300ms. It would be beneficial to make this delay customizable via props, with a default value of 300ms, to enhance flexibility.

  2. Show All People on Focus: The functionality to display all people when the input is focused but empty is missing. Implementing this feature will improve user experience.

  3. Filter Call on Spaces: Ensure that the filter does not trigger when the user enters only spaces. Adding logic to handle this case explicitly will prevent unnecessary operations.

  4. Key Generation: You've switched to using person.slug as the key in the DropdownMenu, which is a good step assuming slug is unique. Double-check that slug is indeed unique for each person to avoid potential rendering issues.

  5. Naming Conventions: Adhering to recommended naming conventions for methods will enhance readability and maintainability. Review your method names to ensure they follow these conventions.

Despite these issues, the decision to approve the pull request is made to help you move forward with your learning. Please review the comments and address these points to improve your code. Keep up the good work and continue learning from these experiences! 🚀

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

Comment on lines +22 to +28
timerId.current = window.setTimeout(() => {
setNormalizedQuery(newQuery.trim().toLowerCase());

if (newQuery !== normalizedQuery) {
setSelectedPerson(null);
}
}, 300);

Choose a reason for hiding this comment

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

The debounce logic is implemented here with a fixed delay of 300ms. However, it should be customizable via props with a default value of 300ms, as per the task requirements.

<div className="dropdown-trigger">
<input
type="text"
placeholder="Enter a part of the name"
className="input"
data-cy="search-input"
value={query}
ref={field}
onFocus={() => setIsFocused(true)}

Choose a reason for hiding this comment

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

The feature to show all people when the input is focused but empty is missing. You should modify the logic to display all people in this case.

value={query}
ref={field}
onFocus={() => setIsFocused(true)}
onChange={event => saveQuery(event.target.value)}

Choose a reason for hiding this comment

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

The filter should not trigger if the user enters only spaces. Consider adding logic to handle this case explicitly.

</div>
{filteredPeople.length > 0 && (
<DropdownMenu
people={filteredPeople}

Choose a reason for hiding this comment

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

Ensure that the DropdownMenu component uses a unique identifier for keys instead of person.name, which might not be unique. Consider using an id or another unique property.

<div className="dropdown-content">
{people.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.

The key for each person in the map function is set to person.slug. Ensure that slug is a unique identifier for each person. If slug is not guaranteed to be unique, consider using a more unique property such as an id.

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