Skip to content

done#1869

Open
annbisha wants to merge 3 commits into
mate-academy:masterfrom
annbisha:master
Open

done#1869
annbisha wants to merge 3 commits into
mate-academy:masterfrom
annbisha:master

Conversation

@annbisha
Copy link
Copy Markdown

No description provided.

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

I am requesting changes because a couple of core checklist requirements are not yet satisfied, even though the overall DOM logic is very close. First, the script currently selects inputs with something like document.querySelectorAll('.field input'), but the task requires that you get all inputs from the form element itself [CHECKLIST ITEM #15]; update the selector so you first select the form and then query its inputs, ensuring the code will still work if the page structure around the fields changes. Second, the assignment instructions state that only src/scripts/main.js should be modified, but your submission also changes README.md [CHECKLIST ITEM #14], so please revert any README changes so only the allowed file is touched. In addition, there is a duplicate 'use strict'; directive at the top of src/scripts/main.js, so keep a single one at the very top and remove the extra copy for cleaner code. As a small UX improvement (not required for passing), consider whether the label should be inserted before the input instead of appended after it, and use parent.insertBefore(label, input) if the intended layout expects labels above inputs. Once you adjust the input selection to be form-based, revert the README, and clean up the extra strict directive, your solution will fully align with the task requirements and should be in great shape.


✨ 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
'use strict';

// write code here
'use strict';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove the duplicate 'use strict' directive — it's declared twice. Keep a single 'use strict' at the top of the file.

Comment thread src/scripts/main.js Outdated
// write code here
'use strict';

const inputs = document.querySelectorAll('.field input');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Per checklist item #15 you should get inputs from the form element. Replace document.querySelectorAll('.field input') with a selection from the form, e.g. document.querySelectorAll('form input') or const form = document.querySelector('form'); const inputs = form.querySelectorAll('input'); so you explicitly pull inputs from the form.

Comment thread src/scripts/main.js Outdated
label.setAttribute('for', input.id);
label.textContent = labelText;

input.parentElement.appendChild(label);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Appending the label with parentElement.appendChild(label) places the label after the input. If the expected layout requires the label before the input, insert it before the input using input.parentElement.insertBefore(label, input); otherwise appending is fine as-is.

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

Changes are needed before this can be accepted because the current PR both violates the file-scope requirement and still fails the end‑to‑end tests.

  1. Critical – Test failures on sign-in fields: The Cypress spec jsTaskFixFormDOM.spec.js reports that #sign-in-email and #sign-in-password do not have placeholder attributes and that their parent elements contain no label elements. This means that, at runtime, your DOM fix is not being applied to the sign‑in form as required (the tests specifically look at that form), so the core behavior is incomplete. In src/scripts/main.js, please double‑check the code near the top where you select the form (e.g., document.querySelector('form')) and get its inputs: ensure you are targeting the form that contains #sign-in-email and #sign-in-password, and that for each of those inputs you (a) set input.placeholder to a capitalized version of input.name, and (b) insert a new label.field-label into the same parent container with label.htmlFor = input.id and text from input.name [CHECKLIST ITEM #15]. After adjusting this logic, re‑run npm test to confirm that all four failing Cypress checks for placeholders and labels on the sign‑in email/password now pass.
  2. Critical – Scope of changes (files touched): The task explicitly requires that only src/scripts/main.js be modified, but your PR also changes README.md, which breaks that constraint [CHECKLIST ITEM #14]. In README.md, around the section where the demo link and instructions live (likely within the first ~30 lines), please revert any edits you made so that the file matches the original starter content and the diff only shows changes to src/scripts/main.js.

Minor suggestion (non‑blocking): In src/scripts/main.js, you may also want to defensively ensure that any input without an id gets one (for example, input.id = input.name) before assigning label.htmlFor, which will make your labels more robust and accessible. Once you’ve fixed the sign‑in form behavior and reverted the README changes, your solution will align well with the requirements and should pass the automated tests.


✨ 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

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

I am approving your solution as an educational override so you can keep progressing, but there are a few important improvements to make next.

In src/scripts/main.js, where you currently use document.querySelectorAll('form') and loop all forms, you should instead locate the sign-in inputs (#sign-in-email / #sign-in-password) and use closest('form') so that your logic clearly targets the correct form as required by [CHECKLIST ITEM #15]. In the block where you assign input.id = inputName when an id is missing, add a guard so that if input.name is empty/undefined you either skip that input or fall back to a safe id like input.id = inputName || `input-${index}` ; this also prevents your labelText calculation (inputName[0].toUpperCase() + inputName.slice(1)) from throwing when inputName is falsy. It would also help to skip setting placeholder on non-textual inputs (like type="submit" or type="button") to avoid unnecessary or confusing DOM changes. Outside of JavaScript, make sure you revert any changes to README.md so that only src/scripts/main.js is modified, matching the scope requirement in [CHECKLIST ITEM #14].

You did a solid job using input.name as the single source of truth for labels, placeholders, and ids, and inserting labels before the inputs with the correct class, so you’re very close—tightening these few details will make your solution both more robust and fully aligned with the checklist.


✨ 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/scripts/main.js
'use strict';

// write code here
const forms = document.querySelectorAll('form');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You call document.querySelectorAll('form') and iterate every form. The task (checklist item #15) requires targeting the form that contains #sign-in-email and #sign-in-password using document.querySelector so the fixes are applied to that specific form. Consider locating the sign-in inputs and using closest('form') (for example: find #sign-in-email and get its closest form) before collecting inputs.

Comment thread src/scripts/main.js
Comment on lines +11 to +13
if (!input.id) {
input.id = inputName;
}
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 branch sets input.id = inputName when input.id is missing. If input.name is empty or missing this will assign an empty id (or duplicate ids). Ensure input.name exists and provide a safe fallback id (for example input.id = inputName || 'input-${index}') to avoid invalid/duplicate ids.

Comment thread src/scripts/main.js
input.id = inputName;
}

const labelText = inputName[0].toUpperCase() + inputName.slice(1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You compute labelText via inputName[0].toUpperCase() + inputName.slice(1) but this will throw if inputName is empty/undefined. Add a guard: only capitalize when inputName is a non-empty string (or fallback to a safe string). Also confirm the label text expected by tests — they expect label text derived from input.name (ensure casing matches test expectations).

Comment thread src/scripts/main.js
const labelText = inputName[0].toUpperCase() + inputName.slice(1);

// placeholder
input.placeholder = labelText;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You set input.placeholder for every input. Consider skipping non-textual input types (e.g., type='submit', type='button') since placeholders don't apply there; this avoids unnecessary DOM changes and potential confusion.

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