Skip to content

Conversation

@pankaj-bind
Copy link

@pankaj-bind pankaj-bind commented Dec 17, 2025

Notes for Reviewers

This PR fixes issue #827 and some more issues

Fix: Prevent default form submission to stop page refresh on Subscribe.
Currently, clicking the Subscribe button refreshes the page, which does not align with modern UX standards. Additionally, users do not receive any feedback indicating whether the subscription was successful or failed.

Validation: Add client-side validation (required + regex) and focus on error.

UX: Prevent unexpected input expansion by removing width change on :focus and adding a subtle border transition.

Signed commits

  • Yes, I signed my commits.

… input expanding on focus

Signed-off-by: Pankaj Kumar Bind <pankajbind30@gmail.com>
Signed-off-by: Pankaj Kumar Bind <pankajbind30@gmail.com>
Copilot AI review requested due to automatic review settings December 17, 2025 12:38
@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for bejewelled-pegasus-b0ce81 ready!

Name Link
🔨 Latest commit bcb623a
🔍 Latest deploy log https://app.netlify.com/projects/bejewelled-pegasus-b0ce81/deploys/6942a9503ad2db0007273c62
😎 Deploy Preview https://deploy-preview-880--bejewelled-pegasus-b0ce81.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #827 by fixing several UX issues with the newsletter subscription form in the footer. The changes prevent page reloads on form submission, add client-side email validation with user feedback, and improve the input field's focus behavior.

Key Changes:

  • Added form submission prevention with e.preventDefault() to stop page refresh
  • Implemented client-side email validation with regex pattern and real-time error messaging
  • Simplified CSS focus styles to prevent unexpected input expansion while maintaining visual feedback

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
layouts/partials/footer.html Added form IDs, email input validation, error message display area, and JavaScript event handlers for form submission and validation
assets/scss/_footer_project.scss Removed width/padding changes on input focus, replaced with subtle border transition for better UX

<div class="row footer-info2 subscribe">
<div class="footer-end">
<form name="contactform">
<form name="contactform" id="newsletter-form">
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

The form lacks an action attribute or backend integration to actually handle newsletter subscriptions. Currently, the form only shows a success message but doesn't submit the email address anywhere. You need to add either a form action URL, integrate with a newsletter service (e.g., Mailchimp, Netlify Forms), or implement an API endpoint to handle the subscription.

Copilot uses AI. Check for mistakes.
Comment on lines 81 to 124
<script>
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('newsletter-form');
const emailInput = document.getElementById('newsletter-email');
const messageDiv = document.getElementById('newsletter-message');

function showMessage(text, isError) {
messageDiv.textContent = text;
messageDiv.style.color = isError ? '#ff6b6b' : '#00d3a9';
}

function clearMessage() {
messageDiv.textContent = '';
}

if (form) {
emailInput.addEventListener('input', clearMessage);

form.addEventListener('submit', function(e) {
e.preventDefault();

const email = emailInput.value.trim();

if (!email) {
showMessage('Please enter your email address', true);
emailInput.focus();
return false;
}

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
showMessage('Please enter a valid email address', true);
emailInput.focus();
return false;
}

showMessage('Thank you for subscribing!', false);
emailInput.value = '';

return false;
});
}
});
</script>
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Consider extracting this JavaScript code into a separate file in assets/js/ (e.g., newsletter-form.js) following the project structure where JavaScript files are kept separate from HTML templates. This improves maintainability and allows for better code organization.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines 87 to 90
function showMessage(text, isError) {
messageDiv.textContent = text;
messageDiv.style.color = isError ? '#ff6b6b' : '#00d3a9';
}
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Hardcoded color values in JavaScript should be moved to CSS classes or variables. Define error and success message styles in the SCSS file (e.g., .newsletter-message--error and .newsletter-message--success) and toggle classes instead of directly manipulating inline styles. This keeps styling consistent with the rest of the project and makes theme changes easier.

Copilot uses AI. Check for mistakes.
Comment on lines 72 to 75
<input class="footer-input" id="newsletter-email" type="email" placeholder="Email Address" required />
<button class="footer-button" title="Subscribe" type="submit">Subscribe</button>
</div>
<div id="newsletter-message" style="margin-top: 0.5rem; font-size: 0.9rem; min-height: 1.5rem;"></div>
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Consider adding aria-describedby="newsletter-message" to the email input and aria-live="polite" to the message div to improve accessibility for screen reader users. This will ensure that validation messages are announced to users who rely on assistive technology.

Suggested change
<input class="footer-input" id="newsletter-email" type="email" placeholder="Email Address" required />
<button class="footer-button" title="Subscribe" type="submit">Subscribe</button>
</div>
<div id="newsletter-message" style="margin-top: 0.5rem; font-size: 0.9rem; min-height: 1.5rem;"></div>
<input class="footer-input" id="newsletter-email" type="email" placeholder="Email Address" required aria-describedby="newsletter-message" />
<button class="footer-button" title="Subscribe" type="submit">Subscribe</button>
</div>
<div id="newsletter-message" aria-live="polite" style="margin-top: 0.5rem; font-size: 0.9rem; min-height: 1.5rem;"></div>

Copilot uses AI. Check for mistakes.
Comment on lines 70 to 76
<div style="display: flex; align-items: flex-start; flex-direction: column;">
<div style="display: flex; align-items: center;">
<input class="footer-input" id="newsletter-email" type="email" placeholder="Email Address" required />
<button class="footer-button" title="Subscribe" type="submit">Subscribe</button>
</div>
<div id="newsletter-message" style="margin-top: 0.5rem; font-size: 0.9rem; min-height: 1.5rem;"></div>
</div>
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Inline styles should be moved to the SCSS file for better maintainability and consistency with the rest of the codebase. Create CSS classes in assets/scss/_footer_project.scss for these layout styles (e.g., .newsletter-wrapper, .newsletter-input-container, .newsletter-message).

Copilot generated this review using guidance from repository custom instructions.
- Extract inline JavaScript to external file (newsletter.js)
- Replace inline styles with CSS classes for better maintainability
- Add proper ARIA labels and semantic HTML for accessibility
- Add JSDoc comments for better code documentation
- Add visually-hidden class for accessible form labels
- Use Hugo asset pipeline for JavaScript loading with defer attribute

Signed-off-by: Pankaj Kumar Bind <pankajbind30@gmail.com>
@pankaj-bind
Copy link
Author

@leecalcote I’ve fixed the issues and made the necessary changes suggested by Copilot.

@pankaj-bind pankaj-bind deleted the fix-footer branch December 17, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant