From 56bc7a6902b20a9bd7c001879228f813236fda8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Jaeger=20Foresti?= <60678893+juliajforesti@users.noreply.github.com> Date: Mon, 11 Sep 2023 11:21:10 -0300 Subject: [PATCH 1/2] fix(fuselage): prevent button-disabled click animation (#1158) --- packages/fuselage/src/styles/primitives/button.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/fuselage/src/styles/primitives/button.scss b/packages/fuselage/src/styles/primitives/button.scss index 4cbbafef70..bdc0b3b3d3 100644 --- a/packages/fuselage/src/styles/primitives/button.scss +++ b/packages/fuselage/src/styles/primitives/button.scss @@ -42,5 +42,9 @@ color: map.get($colors, disabled-color); border-color: map.get($colors, disabled-border-color); background-color: map.get($colors, disabled-background-color); + + * { + transform: none !important; + } } } From 385170c6b338a43200699c004ad39c2d4c3a84ea Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Mon, 11 Sep 2023 22:57:13 +0530 Subject: [PATCH 2/2] fix(fuselage): `AudioPlayer`: `Infinity` duration audio files crashing (#1159) Co-authored-by: Douglas Fabris --- .../components/AudioPlayer/AudioPlayer.tsx | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx index 5c9260f1df..b3c0cd7373 100644 --- a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx +++ b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx @@ -28,6 +28,32 @@ function forceDownload(url: string, fileName?: string) { xhr.send(); } +const getDurationForInfinityDurationAudioFile = ( + src: string, + callback: (duration: number) => void +) => { + const audioElement = new Audio(); + audioElement.src = src; + + audioElement.addEventListener('loadedmetadata', () => { + const { duration } = audioElement; + if (duration === Infinity) { + audioElement.currentTime = 1e101; + return; + } + + return callback(duration); + }); + + audioElement.addEventListener('durationchange', () => { + if (audioElement.duration === Infinity) { + return; + } + callback(audioElement.duration); + audioElement.remove(); + }); +}; + export const AudioPlayer = forwardRef< HTMLAudioElement, { @@ -169,8 +195,14 @@ export const AudioPlayer = forwardRef< onTimeUpdate={(e) => { setCurrentTime((e.target as HTMLAudioElement).currentTime); }} - onLoadedData={(e) => { - setDurationTime((e.target as HTMLAudioElement).duration); + onLoadedMetadata={(e) => { + const { duration } = e.target as HTMLAudioElement; + + if (duration !== Infinity) { + return setDurationTime(duration); + } + + getDurationForInfinityDurationAudioFile(src, setDurationTime); }} onEnded={() => setIsPlaying(false)} ref={refs}