react-spreadsheet-import icon indicating copy to clipboard operation
react-spreadsheet-import copied to clipboard

Add Progress Spinner when hitting the Next button on the Match Columns Step

Open danielletully opened this issue 2 years ago • 3 comments

Just wondering if there is an easy way to add a Progress Spinner when hitting the Next button on the Match Columns Step? My files are taking about 30 seconds to process. Thanks.

danielletully avatar Jan 30 '24 21:01 danielletully

@danielletully I have the same issue. Are you running a custom data hook?

benzler avatar Feb 05 '24 17:02 benzler

@danielletully I have the same issue. Are you running a custom data hook?

I noticed that the loading indicator of the "next" button wasn't triggered when the function wasn't called asynchronously.

Here's how I managed to resolve it:

selectHeaderStepHook={async (
    headerValues: RawData,
    Data: RawData[],
  ) => {
    const d = await new Promise<{
      headerValues: RawData;
      Data: RawData[];
    }>((resolve) => {
      setTimeout(() => {
        const result = doCustomDataMapping(
          headerValues,
          data,
          params,
          fields,
        );
        resolve(result);
      }, 0);
    });
    return d;
  }}

By making the selectHeaderStepHook function asynchronous (async), and awaiting the promise creation using await, it ensures that the loading indicator functions as expected even with the slight delay introduced by setTimeout.

benzler avatar Feb 06 '24 13:02 benzler

@benzler Thank you so much!!! This worked for me!

danielletully avatar Feb 06 '24 19:02 danielletully