Skip to content

Fix: resolve Alarm Button CSP block, scope issues, and audio crash#7271

Open
Souma-122s wants to merge 4 commits into
dhairyagothi:Mainfrom
Souma-122s:fix/alarm-button-csp
Open

Fix: resolve Alarm Button CSP block, scope issues, and audio crash#7271
Souma-122s wants to merge 4 commits into
dhairyagothi:Mainfrom
Souma-122s:fix/alarm-button-csp

Conversation

@Souma-122s
Copy link
Copy Markdown
Contributor

📝 Pull Request Description

Related Issue

Closes #6960

Summary

This PR resolves the critical failure of the "ADD ALARM" button on the Digital Clock project. The root cause was Vercel's strict Content Security Policy (CSP) blocking inline HTML onsubmit and onclick attributes. While addressing this, I also debugged and resolved related scope issues, fixed and audio crash and implemented the missing history logging architecture.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New project addition
  • 🚀 New feature or UI/UX enhancement
  • ♻️ Code refactoring / clean-up
  • 📝 Documentation update
  • ⚙️ GitHub Workflow automation or DX improvements

🛠️ Changes Made

  • CSP Bypass: Removed blocked onsubmit/onclick inline scripts and implemented safe native addEventListener logic for the alarm buttons.
  • Scope Resolution: Fixed a misplaced closing bracket for the DOMContentLoaded event that was accidentally isolating global functions (like Dark Mode and World Clock).
  • Audio Crash Fix: Diagnosed a silent ReferenceError crashing the triggerAlarm function before the .play() method could execute.
  • History Log Implementation: Built the missing addHistoryLog function and formatted the output as an object ({text: message}) to resolve the undefined rendering bug.
  • UI Polish: Added 12H/24H time format synchronization for the generated history logs.

🧪 Testing and Verification

Local Validation

  • I have run node scripts/validateProjects.js locally and it passed with zero errors.

Browser Compatibility Check

  • Tested and verified in Google Chrome
  • Tested and verified in Mozilla Firefox
  • Tested and verified in Safari / Microsoft Edge

Responsive & Accessibility Checks

  • Verified responsive layout on Mobile viewports (using DevTools)
  • Verified responsive layout on Tablet viewports
  • Keyboard navigation and focus outlines checked
  • Semantic HTML and ARIA labels checked


🤝 Contributor Checklist

  • My code follows the code style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation / README files accordingly.
  • My changes generate no new warnings or console errors.
  • There are no unrelated changes or formatter noise in this PR.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 7, 2026

@Souma-122s is attempting to deploy a commit to the Dhairya Gothi 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2026

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

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.

[Bug]: "ADD ALARM" button fails silently due to inline script CSP block

1 participant