Skip to content

Commit

Permalink
[NewEntry] After clicking audio (record/play/pause), focus on gloss f…
Browse files Browse the repository at this point in the history
…ield (#2787)
  • Loading branch information
imnasnainaec authored Nov 15, 2023
1 parent 8947af6 commit d020770
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/DataEntry/DataEntryTable/NewEntry/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export default function NewEntry(props: NewEntryProps): ReactElement {
pronunciationFiles={newAudioUrls}
deleteAudio={delNewAudioUrl}
uploadAudio={addNewAudioUrl}
onClick={() => focus(FocusTarget.Gloss)}
/>
</Grid>
<Grid item xs={1} style={gridItemStyle(1)}>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Pronunciations/AudioPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface PlayerProps {
deleteAudio: (fileName: string) => void;
fileName: string;
isPlaying?: boolean;
onClick?: () => void;
pronunciationUrl: string;
}

Expand Down Expand Up @@ -73,6 +74,9 @@ export default function AudioPlayer(props: PlayerProps): ReactElement {
}

function deleteOrTogglePlay(event?: any): void {
if (props.onClick) {
props.onClick();
}
if (event?.shiftKey) {
setDeleteConf(true);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Pronunciations/AudioRecorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getFileNameForWord } from "components/Pronunciations/utilities";
interface RecorderProps {
wordId: string;
uploadAudio: (audioFile: File) => void;
onClick?: () => void;
}

export default function AudioRecorder(props: RecorderProps): ReactElement {
Expand All @@ -21,6 +22,9 @@ export default function AudioRecorder(props: RecorderProps): ReactElement {
}

async function stopRecording(): Promise<void> {
if (props.onClick) {
props.onClick();
}
const blob = await recorder.stopRecording();
if (!blob) {
toast.error(t("pronunciations.noMicAccess"));
Expand Down
8 changes: 7 additions & 1 deletion src/components/Pronunciations/PronunciationsFrontend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface PronunciationFrontendProps {
elemBetweenRecordAndPlay?: ReactElement;
deleteAudio: (fileName: string) => void;
uploadAudio: (audioFile: File) => void;
onClick?: () => void;
}

/** Audio recording/playing component for audio being recorded and held in the frontend. */
Expand All @@ -21,13 +22,18 @@ export default function PronunciationsFrontend(
key={fileName}
pronunciationUrl={fileName}
deleteAudio={props.deleteAudio}
onClick={props.onClick}
/>
)
);

return (
<>
<AudioRecorder wordId={""} uploadAudio={props.uploadAudio} />
<AudioRecorder
wordId={""}
uploadAudio={props.uploadAudio}
onClick={props.onClick}
/>
{props.elemBetweenRecordAndPlay}
{audioButtons}
</>
Expand Down

0 comments on commit d020770

Please sign in to comment.