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

STCOR-952 break QueryStateUpdates out to their own class-based component. #1604

Merged
merged 9 commits into from
Mar 4, 2025

Conversation

JohnC-80
Copy link
Contributor

@JohnC-80 JohnC-80 commented Feb 25, 2025

Changes from App reordering - specifically a functional refactor of MainNav unearthed a handful of errors at the app level, causing behaviors with logic that updates query parameters/location. This PR takes the previous code from the class-based MainNav and places it in its own component: QueryStateUpdater - naming aside, this removes the potentially offending logic from MainNav, leaving it to the task of simply rendering the navigation/menus of the UI.

The useEffect implementations of the functional MainNav were written to mirror the componentDidMount and componentDidUpdate lifecycle methods of the class-based version. When the location was added to the cDM dependency array in This PR, this meant that the logic would no longer execute stricly on mount/dismount - but anytime that the location updated... this would cause page refreshes, as the logic would find a black prevQueryState every time and always update the location, causing a refresh.

componentDidUpdate carried around its prevProps, unlike functional react, where a state might be needed to accomplish such a comparison - but this doesn't seem like an ideal solution for the functional version, so here we are.

This is better because separately concerned logic is separated... worse because the separated logic still has all of its tentacles into the App layer and seems like a great example of a component that does too much - why wouldn't/couldn't updating queryState/location actually just live at the application level somehow? A question for future FOLIO...

Copy link

github-actions bot commented Feb 25, 2025

Bigtest Unit Test Results

189 tests  ±0   184 ✅ ±0   6s ⏱️ ±0s
  1 suites ±0     5 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 7c45a74. ± Comparison against base commit 97884c1.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Feb 25, 2025

Jest Unit Test Results

  1 files  ±0   65 suites  +1   1m 33s ⏱️ ±0s
383 tests +2  383 ✅ +2  0 💤 ±0  0 ❌ ±0 
387 runs  +2  387 ✅ +2  0 💤 ±0  0 ❌ ±0 

Results for commit 7c45a74. ± Comparison against base commit 97884c1.

♻️ This comment has been updated with latest results.

@JohnC-80 JohnC-80 marked this pull request as ready for review March 3, 2025 21:28
@JohnC-80 JohnC-80 requested a review from a team as a code owner March 3, 2025 21:28
Copy link
Member

@zburke zburke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I appreciate the detailed explanation of why we need this change in the PR description. Consider moving some of into a header comment on QueryStateUpdater to help folks understand why that component exists and that we know about its warts.

Copy link

sonarqubecloud bot commented Mar 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
64.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@JohnC-80 JohnC-80 merged commit 9cbaa1b into master Mar 4, 2025
15 of 16 checks passed
@JohnC-80 JohnC-80 deleted the STCOR-952 branch March 4, 2025 14:36
zburke pushed a commit that referenced this pull request Mar 12, 2025
…ent. (#1604)

Changes from [App
reordering](https://folio-org.atlassian.net/browse/STCOR-936) -
specifically a functional refactor of `MainNav` unearthed a handful of
errors at the app level, causing behaviors with logic that updates query
parameters/location. This PR takes the previous code from the
class-based `MainNav` and places it in its own component:
`QueryStateUpdater` - naming aside, this removes the potentially
offending logic from `MainNav`, leaving it to the task of simply
rendering the navigation/menus of the UI.

The useEffect implementations of the functional `MainNav` were written
to mirror the `componentDidMount` and `componentDidUpdate` lifecycle
methods of the class-based version. When the `location` was added to the
`cDM` dependency array in [This
PR](#1600), this meant
that the logic would no longer execute stricly on mount/dismount - but
anytime that the `location` updated... this would cause page refreshes,
as the logic would find a black `prevQueryState` every time and always
update the location, causing a refresh.

`componentDidUpdate` carried around its `prevProps`, unlike functional
react, where a state might be needed to accomplish such a comparison -
but this doesn't seem like an ideal solution for the functional version,
so here we are.

This is better because separately concerned logic is separated... worse
because the separated logic still has all of its tentacles into the App
layer and seems like a great example of a component that does too much -
why wouldn't/couldn't updating queryState/location actually just live at
the application level somehow? A question for future FOLIO...

(cherry picked from commit 9cbaa1b)
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.

2 participants