Fix progress bar regression throughout the app (#9219) (#9221)

* Fix useSmoothAnimation enablement not working properly by getting rid of it

Passing duration=0 is more logical and less superfluous

* Refactor UploadBar to handle state more correctly

* Change ProgressBar to new useSmoothAnimation signature and default animated to true for consistency

* Add type guard

* Make types stricter

* Write tests for the ProgressBar component

* Make the new test conform to tsc --strict

* Update UploadBar.tsx

* Update UploadBar.tsx

* Update UploadBar.tsx

(cherry picked from commit 9b99c967f4)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
ElementRobot 2022-08-25 16:47:48 +01:00 committed by GitHub
parent 0a0a46c131
commit 877fa9c5c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 105 additions and 37 deletions

View file

@ -25,10 +25,10 @@ interface IProps {
}
const PROGRESS_BAR_ANIMATION_DURATION = 300;
const ProgressBar: React.FC<IProps> = ({ value, max, animated }) => {
const ProgressBar: React.FC<IProps> = ({ value, max, animated = true }) => {
// Animating progress bars via CSS transition isnt possible in all of our supported browsers yet.
// As workaround, were using animations through JS requestAnimationFrame
const currentValue = useSmoothAnimation(0, value, PROGRESS_BAR_ANIMATION_DURATION, animated);
const currentValue = useSmoothAnimation(0, value, animated ? PROGRESS_BAR_ANIMATION_DURATION : 0);
return <progress className="mx_ProgressBar" max={max} value={currentValue} />;
};