Skip to content

add task solution#1113

Open
yana-longstocking wants to merge 2 commits into
mate-academy:masterfrom
yana-longstocking:develop
Open

add task solution#1113
yana-longstocking wants to merge 2 commits into
mate-academy:masterfrom
yana-longstocking:develop

Conversation

@yana-longstocking
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

There is a critical bug that must be fixed: when clicking a different column header, the sort direction is not reset to ASC as required by the specification. The global ascending variable persists across column clicks, causing unexpected DESC sorting when switching to a new column. To fix this, you need to track which column was last sorted and reset ascending = true when a different column is clicked. Additionally, the compareNumericValues and compareCurrencyValues functions receive an asc parameter but ignore it, using the global ascending instead—this inconsistency could cause bugs when these functions are called. Please implement per-column sort state tracking so that sorting a new column always starts in ASC order.


✨ 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/scripts/main.js Outdated
Comment on lines +3 to +14
const table = document.querySelector('table');
let ascending = true;

table.onclick = function (e) {
if (e.target.tagName !== 'TH') {
return;
}

const th = e.target;

sortTable(th.cellIndex);
ascending = !ascending;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The ascending variable is not reset when clicking a new column header. According to the requirements, clicking a new title should always sort in ASC order. Currently, if you sorted one column DESC and then clicked a different column, it would sort DESC instead of ASC.

Fix approach: You need to track which column was last sorted. When a different column is clicked, reset ascending to true before sorting.

Comment thread src/scripts/main.js
Comment on lines +24 to +30

function compareNumericValues(numA, numB, asc = true) {
if (ascending) {
return numA - numB;
}

return numB - numA;
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 compareNumericValues function receives an asc parameter but ignores it, using the global ascending instead. This inconsistency could cause bugs when called from sortTable.

Comment thread src/scripts/main.js
Comment on lines +36 to +45

function compareCurrencyValues(priceA, priceB, asc = true) {
const amountA = parseCurrency(priceA);
const amountB = parseCurrency(priceB);

if (ascending) {
return amountA - amountB;
}

return amountB - amountA;
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 compareCurrencyValues function receives an asc parameter but ignores it, using the global ascending instead. Same inconsistency as numeric comparison.

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

Your solution is approved. All task requirements are met: table sorting correctly toggles between ASC/DESC and resets to ASC when switching columns (using lastSortedColumn tracking), compare functions properly use the asc parameter, row selection applies the 'active' class correctly, the employee form has the correct structure with all required data-qa attributes and 6 office options, form validation handles all required checks (name length, age range, required fields), notifications display with proper styling, salary formatting works correctly, and optional cell editing functions as expected. The critical bugs from previous reviews have been resolved. Great work implementing all features!


✨ 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