Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] IndexTable loading prop does not always re-render loading UI when changed #11803

Closed
LA1CH3 opened this issue Mar 29, 2024 · 1 comment · Fixed by #11805
Closed

[Bug] IndexTable loading prop does not always re-render loading UI when changed #11803

LA1CH3 opened this issue Mar 29, 2024 · 1 comment · Fixed by #11805
Labels
Bug Something is broken and not working as intended in the system. untriaged

Comments

@LA1CH3
Copy link
Contributor

LA1CH3 commented Mar 29, 2024

Summary

Basically, it seems that the loading prop does not re-render the “loading” banner when the loading prop changes. In fact, it seems you can basically never go from false to true and see it re-render. Only if you are going from true to false will you see it. So, if the table is initially rendered with loading={true} and then you have some flag that sets loading={false} will you see it disappear. But if the table initially renders with loading={false} and then some action causes loading={true} , the banner does not appear.

Expected behavior

The "loading <resource name>" UI should re-appear whenever the loading prop changes to true.

Actual behavior

Example codesandbox

Once the IndexTable is at any time rendered with loading={false}, the "Loading" UI will never be shown until the component is completely re-mounted.

Steps to reproduce

Link to sandbox

  1. Click "Toggle loading"
  2. Observe the "loading" UI does not show
  3. In the code, change the default value of isLoading to true
  4. Observe loading UI is shown.
  5. Click "Toggle loading" and observe loading UI goes away.
  6. Try clicking "Toggle loading" again and observe loading UI does not re-appear.

Are you using React components?

Yes

Polaris version number

12.23.0

Browser

Chrome

Device

Macbook

@LA1CH3 LA1CH3 added Bug Something is broken and not working as intended in the system. untriaged labels Mar 29, 2024
@remy727
Copy link

remy727 commented Apr 22, 2024

+1 on this issue. I am having the same issue.

LA1CH3 added a commit that referenced this issue Apr 24, 2024
<!--
  ☝️How to write a good PR title:
- Prefix it with [ComponentName] (if applicable), for example: [Button]
  - Start with a verb, for example: Add, Delete, Improve, Fix…
  - Give as much context as necessary and as little as possible
  - Open it as a draft if it’s a work in progress
-->

### WHY are these changes introduced?

Closes #11803 <!-- link to
issue if one exists -->

Fixes an issue where the `loading` prop on `IndexTable` would not
trigger the "loading panel" to appear. This was due to the
`CSSTransition` component not functioning as expected and not applying
expected CSS classes.

I opted to ditch `CSSTransition` altogether and just directly apply the
transitions in CSS for a simpler approach.

<!--
  Context about the problem that’s being addressed.
-->

### WHAT is this pull request doing?

[Example in
`web`](https://admin.web.pf-variants-save-refetch-after.jay-laiche.us.spin.dev/store/shop1/products/2)

- Make price changes to any variants in the "variants" card and save the
product
- Observe that the "Loading variants..." panel appears after save,
indicating reloading/refreshing of variants. It should disappear once
reloading is complete.

<details>
<summary>Example video from storybook</summary>


https://github.com/Shopify/polaris/assets/11605788/5b7b9e06-b268-41ba-ada2-8a4ccdd64bb6

</details>

<!--
  Summary of the changes committed.

Before / after screenshots are appreciated for UI changes. Make sure to
include alt text that describes the screenshot.

  Include a video if your changes include interactive content.

If you include an animated gif showing your change, wrapping it in a
details tag is recommended. Gifs usually autoplay, which can cause
accessibility issues for people reviewing your PR:

  <details>
    <summary>Summary of your gif(s)</summary>
    <img src="..." alt="Description of what the gif shows">
  </details>
-->

### How to 🎩

🖥 [Local development
instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces)
🗒 [General tophatting
guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md)
📄 [Changelog
guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog)

### 🎩 checklist

- [x] Tested a
[snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases)
- [x] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [x] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [x] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken and not working as intended in the system. untriaged
Projects
None yet
2 participants