Skip to content

Fix: prevent theme icon crash and escape apostrophes in onclick handl… - #11006

Merged
dhairyagothi merged 1 commit into
dhairyagothi:Mainfrom
Tejaswini-35433:fix/theme-icon-crash-and-onclick-apostrophe
Aug 7, 2026
Merged

dhairyagothi merged 1 commit into
dhairyagothi:Mainfrom
Tejaswini-35433:fix/theme-icon-crash-and-onclick-apostrophe

Conversation

@Tejaswini-35433

@Tejaswini-35433 Tejaswini-35433 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

📝 Pull Request Description
Related Issue
Closes #10694

Summary
Fixes two bugs in the Animated Search Bar's script: a crash when #themeIcon doesn't exist on the page, and a broken "Search Again"/voice-search button when the query contains an apostrophe.

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

  • Wrapped themeIcon.textContent assignments in updateTheme() with a null check (if (themeIcon) { ... }), so the script no longer throws TypeError: Cannot set properties of null on pages where #themeIcon is absent.
  • Removed the inline onclick="performGoogleSearch('${query}')" pattern for the "Search Again" / voice-search result buttons. The query is now stored safely in a data-query attribute (escaped via escapeHtml()), and a proper addEventListener('click', ...) handler reads it and calls performGoogleSearch(). This avoids breaking out of the inline string when the query contains an apostrophe, since there's no longer an inline JS string to break out of.

🧪 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

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

@Tejaswini-35433 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

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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! 😊

@Tejaswini-35433

Copy link
Copy Markdown
Contributor Author

hii @dhairyagothi ! , I have successfully edited the code, kindly consider merging this to the main branch, happy to make any relevant changes if needed!

@dhairyagothi dhairyagothi added gssoc:approved Approved by admin level:beginner Beginner difficulty task type:refactor Refactoring/improvement labels Aug 7, 2026
@dhairyagothi
dhairyagothi merged commit 78f8cd5 into dhairyagothi:Main Aug 7, 2026
4 of 5 checks passed
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀

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

Labels

gssoc:approved Approved by admin level:beginner Beginner difficulty task type:refactor Refactoring/improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Theme icon crashes script + broken onclick with apostrophes in Animated Search Bar

2 participants