Skip to content

Commit

Permalink
fix(web/progressbar): fix progressbar getting stuck on screen
Browse files Browse the repository at this point in the history
Chakra's ScaleFade transition was causing the progress bar not to rerender properly
  • Loading branch information
LukeWasTakenn committed May 10, 2022
1 parent bc6a6c7 commit 9c7d9c4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions web/src/features/progress/Progressbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Text, Flex, Box, ScaleFade } from "@chakra-ui/react";
import { Text, Flex, Box } from "@chakra-ui/react";
import { useNuiEvent } from "../../hooks/useNuiEvent";
import { debugData } from "../../utils/debugData";
import { fetchNui } from "../../utils/fetchNui";
Expand Down Expand Up @@ -40,7 +40,6 @@ const Progressbar: React.FC = () => {
useNuiEvent("progressCancel", progressCancel);

useNuiEvent<Props>("progress", (data) => {
if (visible) return;
setCancelled(false);
setVisible(true);
setLabel(data.label);
Expand All @@ -57,7 +56,7 @@ const Progressbar: React.FC = () => {
alignItems="center"
>
<Box width={350}>
<ScaleFade in={visible} unmountOnExit>
{visible && (
<Box
height={45}
bg="rgba(0, 0, 0, 0.6)"
Expand All @@ -72,11 +71,14 @@ const Progressbar: React.FC = () => {
sx={
!cancelled
? {
width: "0%",
backgroundColor: "green.400",
animation: `progress-bar linear ${duration}ms`,
animation: "progress-bar linear",
animationDuration: `${duration}ms`,
}
: {
width: "100%",
animationPlayState: "paused",
backgroundColor: "rgb(198, 40, 40)",
}
}
Expand All @@ -94,7 +96,7 @@ const Progressbar: React.FC = () => {
{label}
</Text>
</Box>
</ScaleFade>
)}
</Box>
</Flex>
);
Expand Down

0 comments on commit 9c7d9c4

Please sign in to comment.