Skip to content

Conversation

@Iswanna
Copy link

@Iswanna Iswanna commented Dec 9, 2025

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I fixed the initial render so books show on load (closing the for-loop parenthesis), resolved the add-book console error by pushing to myLibrary, corrected the add-book form to use author.value instead of the title for the author, repaired the Delete button by using a consistent variable name and the proper click event, and corrected the read-status logic so that clicking Read shows Yes in the Read column, and leaving it unchecked shows No.

Questions

Hi. Please could you review my PR? I’d really appreciate your feedback.

@Iswanna Iswanna added 🏕 Priority Mandatory This work is expected 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Flows The name of the module. labels Dec 9, 2025
@Iswanna Iswanna force-pushed the feature/book-library branch from 9f10ac7 to 07c6620 Compare December 9, 2025 14:27
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Can you check if any of this general feedback can help you further improve your code?
https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 9, 2025
@Iswanna
Copy link
Author

Iswanna commented Dec 10, 2025

Can you check if any of this general feedback can help you further improve your code? https://github.com/cjyuan/Module-Data-Flows/blob/book-library-feedback/debugging/book-library/feedback.md

Doing so can help me speed up the review process. Thanks.

Thank you @cjyuan for sharing the link. I'll go through each point carefully and work on the improvements suggested in the feedback file.

…add proper addEventListener on submit button to avoid global scope usage and ensure modern JS practices
… page count is stored consistently as a number, and remove unused id attributes from dynamically created buttons
…ames (titleInput, authorInput, pagesInput, readCheckbox) to avoid confusion with Book object properties
- Replace per-row deletion with a single tbody.innerHTML = "" operation
- Preserves the thead header and reduces DOM work during updates
- No functional UI changes; improves performance on larger lists
- Replace pre-delete alert with confirm dialog
- Delete immediately upon confirmation and re-render
- Display temporary success message that auto-fades without blocking UI
@Iswanna
Copy link
Author

Iswanna commented Dec 10, 2025

Hi @cjyuan.

I have made changes to my codebase based on the feedback in the link you shared. Could you please review the updated code?

Thank you!

@Iswanna Iswanna requested a review from cjyuan December 10, 2025 15:13
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Changes look great.

Input validation could use some improvement.

Comment on lines 37 to 52
function showSuccess(message) {
const alertEl = document.createElement("div");
alertEl.className = "alert alert-success";
alertEl.textContent = message;
alertEl.style.position = "fixed";
alertEl.style.top = "1rem";
alertEl.style.right = "1rem";
alertEl.style.zIndex = "1050";
document.body.appendChild(alertEl);

setTimeout(() => {
alertEl.style.transition = "opacity 0.3s";
alertEl.style.opacity = "0";
setTimeout(() => alertEl.remove(), 300);
}, 2500);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

(Optional)
Could consider designating an element in index.html to display the message. This way, we can have more control where to position the element.

Separation of concern -- We should avoid specifying CSS styles in JS or in HTML file. (Assigning CSS class is ok)

It is possible to create the effect of "making the foreground visible for a fixed amount of time" using only CSS. And then in JS we can just add/remove CSS class to trigger the animation without using setTimeout().

Copy link
Author

@Iswanna Iswanna Dec 11, 2025

Choose a reason for hiding this comment

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

Thank you for the suggestion. I’ve made the updates to the code based on your feedback.

}

// Validate pages
if (Number.isNaN(pages) || pages <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some invalid "number of pages" can still pass this check.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the feedback. I have updated the code to fix this bug.

@cjyuan
Copy link
Contributor

cjyuan commented Dec 10, 2025

You should also change the label to "Needs review" when the PR is ready to be re-reviewed.

…ove inline styles/timeouts

- Add dedicated notice container (#alerts) for controlled placement
- Move toast styling to CSS (.notice-root, .notice, .notice--auto-hide, keyframes)
- Update showSuccess to add classes and remove on animationend (no setTimeout)
- Keep existing behaviors (submit prevention, delete confirm, table re-render) intact
- Use valueAsNumber and input validity (valueMissing, rangeUnderflow, stepMismatch)
- Reject non-numeric and decimal values; enforce min=1 and step=1
- Preserve existing submit handling and notice behavior
@Iswanna
Copy link
Author

Iswanna commented Dec 11, 2025

You should also change the label to "Needs review" when the PR is ready to be re-reviewed.

Thanks for highlighting that! I’ll make sure to set the “Needs review” label when the PR is ready again.

@Iswanna
Copy link
Author

Iswanna commented Dec 11, 2025

Hi @cjyuan.

Thanks for the feedback! I’ve updated the codebase and would appreciate another review.

@Iswanna Iswanna added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Dec 11, 2025
@Iswanna Iswanna requested a review from cjyuan December 11, 2025 10:54
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Changes look good.

Comment on lines 72 to 87
const pages = pagesInput.valueAsNumber;
const v = pagesInput.validity;

if (v.valueMissing || !Number.isFinite(pages)) {
alert("Pages is required and must be a number.");
return;
}
if (v.rangeUnderflow || pages < 1) {
alert("Pages must be at least 1.");
return;
}
// Enforce whole numbers only (reject decimals like 3.5)
if (v.stepMismatch || !Number.isInteger(pages)) {
alert("Pages must be a whole number.");
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking !Number.isInteger(pages) || pages < 1 would be enough.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 11, 2025
@Iswanna
Copy link
Author

Iswanna commented Dec 11, 2025

Thank you so much @cjyuan, for reviewing my PR and giving detailed feedback. I really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Flows The name of the module. 🏕 Priority Mandatory This work is expected 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants