adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.63k stars 1.09k forks source link

ProgressBar does not show fast updates correctly #1104

Open kaiortmanns opened 3 years ago

kaiortmanns commented 3 years ago

πŸ› Bug Report

ProgressBar does not show fast updates correctly like showing download progress of a file.

πŸ€” Expected Behavior

Show progress according to updates.

😯 Current Behavior

Progress updates are manipulated by a CSS transition which is why fast updates donΒ΄t get reflected correctly.

πŸ’ Possible Solution

Add option to turn off CSS transition.

πŸ”¦ Context

Showing progress for file downloads with fast progress updates.

πŸ’» Code Sample

import { darkTheme, ProgressBar, Provider } from '@adobe/react-spectrum'
import React, { PureComponent } from 'react'

type ProgressAppProps = {}

type ProgressAppState = {
  value: number
}

export default class ProgressApp extends PureComponent<ProgressAppProps, ProgressAppState> {
  constructor(props: ProgressAppProps) {
    super(props)

    this.state = {
      value: 0,
    }

    this.updateValue()
  }

  updateValue(): void {
    const { value } = this.state
    if (value < 100) {
      this.setState({ value: value + 1 })

      setTimeout(() => {
        this.updateValue()
      }, 20)
    }
  }

  render(): JSX.Element {
    const { value } = this.state

    return (
      <Provider theme={darkTheme} height='100%'>
        <ProgressBar label='test' value={value} />
      </Provider>
    )
  }
}

🌍 Your Environment

Software Version(s)
react-spectrum 3.3.0
Browser Chrome
Operating System MacOS

🧒 Your Company/Team

Adobe

πŸ•· Tracking Issue (optional)

NA

devongovett commented 3 years ago

I wonder if we could automatically disable the transition if updates are occurring quickly?