unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
4k stars 468 forks source link

Workspace renaming doesn't show a loading indicator #877

Closed chronark closed 8 months ago

chronark commented 8 months ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Issue Summary

The "Save" button should show a loading spinner during the mutation

CleanShot 2024-01-25 at 10 02 59

Steps to Reproduce

  1. go to /app/settings/general
  2. change the name of the workspace
  3. click save

Expected behavior

It should display a loading spinner

Other information

No response

Screenshots

No response

Version info

- OS:
- Node:
- npm:
linear[bot] commented 8 months ago

ENG-488 Workspace renaming doesn't show a loading indicator

ashrafchowdury commented 8 months ago

I would like to raise a PR for this bug πŸ™Œ

AkshayBandi027 commented 8 months ago

hey @chronark, I have noticed that form.formState.isSubmitting has been directly used without invoked or subscribed to.

` <Button variant={form.formState.isSubmitting ? "disabled" : "primary"} type="submit" disabled={form.formState.isSubmitting}

{form.formState.isSubmitting ? : "Save"} `

official docs stats - formState is wrapped with a Proxy to improve render performance and skip extra logic if specific state is not subscribed to. Therefore make sure you invoke or read it before a render in order to enable the state update.

But I have also tried to destruct the formState from form to read isSubmitting before using as the state update but it didn't work.

const {formState:{isSubmitting}} = form `<Button variant={isSubmitting ? "disabled" : "primary"} type="submit" disabled={isSubmitting}

{isSubmitting? : "Save"} `

We make use of react query's isLoading property from updateName mutation and It works.

` <Button variant={updateName.isLoading ? "disabled" : "primary"} type="submit" disabled={updateName.isLoading}

{updateName.isLoading ? : "Save"} `

https://github.com/unkeyed/unkey/assets/100031493/33c3511e-25a6-407a-8a94-6aab82e2052d

chronark commented 8 months ago

Ah very nice, thanks for digging in, then let's use the mutation state πŸ‘

AkshayBandi027 commented 8 months ago

925

hey @chronark , I have also created a PR, please do check it out !☺️