Skip to content

Commit

Permalink
Fix bug where "Cancel Speaking" doesn't make the button active again
Browse files Browse the repository at this point in the history
  • Loading branch information
YummyBacon5 authored Feb 5, 2024
1 parent bd97935 commit efe275c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/DfnArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export default function DfnArea({ word }: DfnAreaProps) {
function speakWord() {
window.speechSynthesis.cancel();

if(isSpeaking) return;
if(isSpeaking) {
setIsSpeaking(false);
return;
}

const utterance = new SpeechSynthesisUtterance(wordData.word);
const voices = window.speechSynthesis.getVoices();
Expand Down Expand Up @@ -116,7 +119,7 @@ export default function DfnArea({ word }: DfnAreaProps) {
onClick={speakWord}
className="speak-button"
aria-label={isSpeaking ? "Cancel speaking" : "Speak word"}
aria-disabled={isSpeaking}
aria-pressed={isSpeaking}
>
<AudioIcon />
</button>
Expand Down

0 comments on commit efe275c

Please sign in to comment.