DevDisplay icon indicating copy to clipboard operation
DevDisplay copied to clipboard

Fix VoiceSearch TypeError in Firefox

Open Ayushi227 opened this issue 7 months ago • 65 comments

Description

Added a check for browser. As the speech recognition implemented does not function on firefox browser, the program throws an error - Screenshot 2026-04-16 at 2 56 03 PM

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. Uploading Screenshot 2026-04-16 at 2.58.20 PM.png…

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.

Ayushi227 avatar Apr 16 '26 05:04 Ayushi227

Review PR in StackBlitz Codeflow 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.

vercel[bot] avatar Apr 16 '26 05:04 vercel[bot]

📝 Walkthrough

Walkthrough

The VoiceSearch component was refactored to improve React lifecycle management by moving SpeechRecognition initialization from module scope into a 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.jsx
Migrated 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

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

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

🚥 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 16 '26 05:04 coderabbitai[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 16 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 17 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 18 '26 05:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 19 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 20 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 21 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 22 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 23 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 24 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 25 '26 05:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 26 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 27 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 28 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 29 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar Apr 30 '26 06:04 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar May 01 '26 06:05 github-actions[bot]

Hi there! This issue is still open. We are looking forward to your response. Assignees: None

github-actions[bot] avatar May 02 '26 06:05 github-actions[bot]