-
-
Notifications
You must be signed in to change notification settings - Fork 158
West Midlands | 25 Sep ITP | Iswat Bello | Sprint 2 | Book library #349
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
base: main
Are you sure you want to change the base?
Conversation
…and unchecked shows “No”
…double render on load
9f10ac7 to
07c6620
Compare
cjyuan
left a comment
There was a problem hiding this 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.
Thank you @cjyuan for sharing the link. I'll go through each point carefully and work on the improvements suggested in the feedback file. |
…nput type="author"/> to type="text"
…add proper addEventListener on submit button to avoid global scope usage and ensure modern JS practices
…listener in script.js
… 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
…” in populateStorage()
…e Submit a button to pass W3C validation
|
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! |
cjyuan
left a comment
There was a problem hiding this 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.
| 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); | ||
| } |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
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.
debugging/book-library/script.js
Outdated
| } | ||
|
|
||
| // Validate pages | ||
| if (Number.isNaN(pages) || pages <= 0) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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
Thanks for highlighting that! I’ll make sure to set the “Needs review” label when the PR is ready again. |
|
Hi @cjyuan. Thanks for the feedback! I’ve updated the codebase and would appreciate another review. |
cjyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good.
| 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; | ||
| } |
There was a problem hiding this comment.
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.
|
Thank you so much @cjyuan, for reviewing my PR and giving detailed feedback. I really appreciate it. |
Learners, PR Template
Self checklist
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 useauthor.valueinstead of the title for the author, repaired theDeletebutton by using a consistent variable name and the properclickevent, and corrected the read-status logic so that clicking Read showsYesin the Read column, and leaving it unchecked showsNo.Questions
Hi. Please could you review my PR? I’d really appreciate your feedback.