Fix VoiceSearch TypeError in Firefox
Description
Added a check for browser. As the speech recognition implemented does not function on firefox browser, the program throws an error -
Related Issues
[Bug]: Website not working on Firefox - https://github.com/codeaashu/DevDisplay/issues/1234
Changes Proposed
The change I am proposing is to add a small display message to the user stating that speech recognition is not supported in firefox, and bypass the use of speech recognition on firefox. The rest of the page functions as is.
Checklist
- [x] I have read and followed the Contribution Guidelines.
- [ ] All new and existing tests passed.
- [ ] I have updated the documentation to reflect the changes I've made.
- [x] My code follows the code style of this project.
- [ ] The title of my pull request is a short description of the requested changes.
Screenshots
Note to reviewers
Summary by CodeRabbit
- Bug Fixes
- Added notification informing Firefox users about voice search availability in their browser.
- Improved voice search stability and error handling to prevent crashes and provide better feedback on failures.
- Enhanced cleanup procedures during component lifecycle for more consistent and reliable behavior.
Run & review this pull request in StackBlitz Codeflow.
Someone is attempting to deploy a commit to the icecream's projects Team on Vercel.
A member of the Team first needs to authorize it.
The VoiceSearch component was refactored to improve React lifecycle management by moving SpeechRecognition initialization from module scope into a 🎯 3 (Moderate) | ⏱️ ~20 minutes 🐰 Voice search gets a refresh, hooks take the stage,
Firefox finds mercy on this careful page,
Lifecycle flows clean, from mount to the end,
A ref and a state, on which we depend,
Listen or not—the choice is now true! ✏️ Tip: You can configure your own custom pre-merge checks in the settings.📝 Walkthrough
Walkthrough
useEffect hook using a ref. Firefox browser detection was added with conditional initialization and a user-facing notification for unsupported browsers, along with enhanced error handling.Changes
Cohort / File(s)
Summary
VoiceSearch Lifecycle & Browser Compatibility Refactor
src/components/Search/VoiceSearch.jsxMigrated SpeechRecognition initialization from module scope to
useEffect with proper cleanup. Added Firefox detection via navigator.userAgent to skip initialization and display a dismissible notification. Introduced useRef for recognition instance management and useState for notification state. Event handlers now set within effect, with separate effect handling start/stop logic wrapped in try/catch with error logging. Conditional rendering prevents listening UI display on Firefox.Estimated code review effort
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Docstring Coverage
⚠️ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title clearly and specifically summarizes the main change—fixing a TypeError in VoiceSearch that occurs in Firefox, which matches the core issue being addressed.
Description check
✅ Passed
The pull request description includes all required template sections: description of the issue, related issues link, detailed changes proposed, and a completed checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None
Hi there! This issue is still open. We are looking forward to your response. Assignees: None