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

fix(ui): freight assembly tables keep resetting to page 1 #3246

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aayushsrivastava
Copy link

@aayushsrivastava aayushsrivastava commented Jan 11, 2025

fixes: #2581

RCA:

  1. The ImageTable/CommitTable/ChartTable component gets re-mounted (unmounted and mounted again) when the select function is called. This leads to the loss of any local state in these components (including the active page).
  2. The select function modifies a state in the AssembleFreight component.
  3. The DiscoveryTable component (which wraps the ImageTable/CommitTable/ChartTable component) is a nested function inside AssembleFreight. Every time AssembleFreight rerenders due to a change in its state, the DiscoveryTable function is redeclared, changing its memory reference. React thinks the component has been replaced, unmounts the old Table, and mounts a new one.

This problem is also described here: https://stackoverflow.com/a/64211013

@aayushsrivastava aayushsrivastava requested a review from a team as a code owner January 11, 2025 18:37
Copy link

netlify bot commented Jan 11, 2025

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 7ff94ad
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-io/deploys/67849a7ede43a600082e50c6
😎 Deploy Preview https://deploy-preview-3246.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aayushsrivastava aayushsrivastava marked this pull request as draft January 11, 2025 19:19
@aayushsrivastava aayushsrivastava marked this pull request as ready for review January 11, 2025 19:34
@aayushsrivastava
Copy link
Author

After fixing the original bug, I noticed that the page still resets to 1 when you change the type of artifact. The second commit fixes that issue by calculating and setting the expected page when the table first mounts.

@aayushsrivastava
Copy link
Author

Screen.Recording.2025-01-12.at.2.31.28.PM.mov

@aayushsrivastava aayushsrivastava changed the title fix(ui): selecting freight in assembly resets the view to page 1 fix(ui): freight assembly tables keep resetting to page 1 Jan 12, 2025
…sembleFreight component

Signed-off-by: Aayush Srivastava <aayushsrivastava.work@gmail.com>
…cted row when it is first mounted

Signed-off-by: Aayush Srivastava <aayushsrivastava.work@gmail.com>
Signed-off-by: Aayush Srivastava <aayushsrivastava.work@gmail.com>
Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.05%. Comparing base (32291db) to head (7ff94ad).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3246   +/-   ##
=======================================
  Coverage   52.05%   52.05%           
=======================================
  Files         295      295           
  Lines       26695    26695           
=======================================
  Hits        13895    13895           
  Misses      12041    12041           
  Partials      759      759           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(ui): selecting freight in assembly resets the view
1 participant