stopPropagation is a method on Event.prototype that uses this internally. When destructured ({ stopPropagation }), it loses its binding to the event object, so calling stopPropagation() throws a TypeError — which silently prevents toggleSavedSound and addSoundToTimeline from ever executing.
Using e.stopPropagation() keeps the method bound to the event. Both buttons should work now.
This commit is contained in:
parent
26d523ebad
commit
43bfdcdb93
|
|
@ -504,17 +504,15 @@ function AudioItem({ sound, isPlaying, onPlay }: AudioItemProps) {
|
|||
onPlay({ sound });
|
||||
};
|
||||
|
||||
const handleSaveClick = ({
|
||||
stopPropagation,
|
||||
}: React.MouseEvent<HTMLButtonElement>) => {
|
||||
stopPropagation();
|
||||
const handleSaveClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.stopPropagation();
|
||||
toggleSavedSound({ soundEffect: sound });
|
||||
};
|
||||
|
||||
const handleAddToTimeline = async ({
|
||||
stopPropagation,
|
||||
}: React.MouseEvent<HTMLButtonElement>) => {
|
||||
stopPropagation();
|
||||
const handleAddToTimeline = async (
|
||||
e: React.MouseEvent<HTMLButtonElement>,
|
||||
) => {
|
||||
e.stopPropagation();
|
||||
await addSoundToTimeline({ sound });
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue