Skip to content

Add solution#1134

Open
Kobeliukh wants to merge 3 commits intomate-academy:masterfrom
Kobeliukh:develop
Open

Add solution#1134
Kobeliukh wants to merge 3 commits intomate-academy:masterfrom
Kobeliukh:develop

Conversation

@Kobeliukh
Copy link
Copy Markdown

Copy link
Copy Markdown

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

Review Summary

This is a solid implementation, but I'm requesting a few changes to fully meet the task requirements. The Dropdown component is missing the required delay prop for customizing the debounce time; it's currently hardcoded. Additionally, the filtering logic should handle whitespace-only input by using trim() on the query before checking if it's empty, as specified in [CHECKLIST ITEM #1]. Lastly, please remember to follow the naming conventions by renaming the onTextChange event handler to handleTextChange. After these adjustments, your solution will be ready!


✨ 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 on lines +6 to +9
interface Props {
people: Person[];
onSelected: (value: Person | null) => void;
}
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 component should accept a delay prop to customize the debounce time, as stated in the requirements. The default value should be 300ms.

Comment thread src/components/Dropdown/Dropdown.tsx Outdated
const [isPersonSelected, setIsPersonSelected] = useState(false);
const [isOpen, setIsOpen] = useState(false);

const onTextChange = (event: React.ChangeEvent<HTMLInputElement>) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the naming conventions mentioned in checklist item #4, event handler functions defined within the component should be prefixed with handle. This function should be named handleTextChange.

Comment thread src/components/Dropdown/Dropdown.tsx Outdated
useEffect(() => {
const timerId = setTimeout(() => {
setFilterQuery(inputText);
}, 1000);
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 debounce delay is hardcoded. It should use the delay prop as required by the task, with a default of 300ms.

Comment thread src/components/Dropdown/Dropdown.tsx Outdated
}, [inputText]);

const filteredPeople = useMemo(() => {
if (!filterQuery) {
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 is triggered even for input containing only spaces. You should trim() the filterQuery before checking if it's empty to prevent this. This violates checklist item #1: 'make sure that filter won't be called if user enred spaces only'.

Copy link
Copy Markdown

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

Review Summary

Great progress on this! The core functionality is looking solid. However, a few changes are needed to meet all the task requirements before this can be approved.

Here are the specific items to address in src/components/Dropdown/Dropdown.tsx:

  1. Default Delay: The default value for the delay prop is currently 1000ms, but the requirement specifies it should be 300ms.
  2. Whitespace Filtering: The filter is still triggered for inputs containing only spaces. To fix this, please trim the query value before checking if it's empty to decide whether to run the filter. This addresses checklist item #1.
  3. Naming Convention: The event handler onTextChange should be renamed to handleTextChange to align with the project's naming conventions from checklist item #4.

Once these adjustments are made, it should be all set. Keep up the excellent work!


✨ 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/components/Dropdown/Dropdown.tsx Outdated
export const Dropdown = ({
people,
onSelected,
delay = 1000,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work making the delay customizable! However, the task description specifies that the default value for the delay should be 300ms.

Comment thread src/components/Dropdown/Dropdown.tsx Outdated
const [isPersonSelected, setIsPersonSelected] = useState(false);
const [isOpen, setIsOpen] = useState(false);

const onTextChange = (event: React.ChangeEvent<HTMLInputElement>) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To follow the naming conventions outlined in checklist item #4, this event handler should be named handleTextChange.

Comment thread src/components/Dropdown/Dropdown.tsx Outdated
}, [inputText]);

const filteredPeople = useMemo(() => {
if (!filterQuery) {
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 check doesn't account for a string that contains only whitespace (e.g., ' '). In that case, filterQuery is truthy, and the filtering logic runs unnecessarily. To meet the requirement from checklist item #1, you should check the trimmed query, for example: if (!filterQuery.trim()).

Copy link
Copy Markdown

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

Review Summary

Excellent work on this submission! I'm happy to approve your solution. You've successfully addressed all the previous feedback, and the component is now working perfectly. It's great to see that you've implemented the correct default delay, handled whitespace inputs, and followed the naming conventions. The code is clean, well-structured, and fully meets all the requirements. Well done!


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

Footnotes

  1. Rate AI review example

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