equinor / design-system

The Equinor design system
MIT License
121 stars 64 forks source link

Feature request: Clickable components should take a promise, and be disabled while running #3618

Closed Richard87 closed 2 months ago

Richard87 commented 2 months ago

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

When a button is clicked, a common use case is to trigger a async function and resolving a Promise, during which we most of the time does not want the button to be clickable.

Describe the solution you'd like

the Buttons onClick handler should set its state to disabled and disable clicking and show a disabled state. When the promise is completed (with our without failure), the state should be reverted back to normal

Describe alternatives you've considered

Creating my own custom Button that encapsulates EDS Button

A clear and concise description of any alternative solutions or features you've considered.

Additional context

I think many would appreciate this feature, and some unknown bugs would be solved, also it would make it easier to start using while the rest of the team is used to import EDS Button instead of a custom on.

oddvernes commented 2 months ago

I think this is a bit outside of our scope. Eds components are mostly supposed to be minimal building blocks without too much custom logic, but can be further expanded from the outside of the component itself. You have all the features (disabled/aria-disabled, CircularProgress indicator) needed to implement this with a wrapper i believe 🙂

Richard87 commented 2 months ago

Okay, then I'll go and make it myself! :)