Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
82 stars 9 forks source link

`<form data-save-bar>` does not disable buttons or show loading indicator on form submission #335

Open darrynten opened 2 months ago

darrynten commented 2 months ago

Describe the bug

When using the form managed contextual save bar (i.e. just <form data-save-bar> without any ui-save-bar component) the discard and submit buttons do not get disabled or enter a loading state once a user has submitted the form.

This results in:

To Reproduce

Steps to reproduce the behaviour:

  1. Add a <form data-save-bar> to a page without any ui-save-bar elements
  2. Setup a non-remix, non-react backend api somewhere to capture the form submissions and update some database field to the received value
  3. Open browser devtools and enable network throttling to 1kbps
  4. Click the save button
  5. While the form is being submitted, click save again and see a second form submission
  6. While waiting for both form submissions click the discard button
  7. Your browser value will now differ from the twice updated backend value

Expected behaviour

Both buttons should enter a disabled state as soon as the save button is clicked the first time to prevent the above issues.

Ideally the "save" button should also enter a loading state.

The buttons should only be re-enabled after the network response has been received or an error has been caught.

Contextual information

Packages and versions

List the relevant packages you’re using, and their versions. For example:

Platform

Additional context

Add any other context about the problem here, such as your app’s configuration (Node, Next.js, Rails).