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 page navigation when using returnUrl #2970

Merged
merged 5 commits into from
Feb 10, 2025
Merged

Conversation

bjosttveit
Copy link
Member

@bjosttveit bjosttveit commented Feb 5, 2025

Description

The problem in the linked issue stemmed from how we figured out the next page when using navigateToNextPage. It would look at the raw url and split on ? and take the first part, assuming those only appear in the end of the hash part. But, when using a returnUrl, that is a "real" queryParameter before the hash even begins, so it would effectively remove all of the information in the hash and the next page could not be determined.

I cleaned up the logic surrounding this, and also made some other changes. I tried to address the issues that caused us to add the hotfix where we disable the navigation buttons while saving. Instead, I now wait for saving after the button is clicked, showing a spinner on the one you clicked (next / previous) and disabling the other. Another issue I noticed when doing this is that the page order can change due to expressions after clicking the button now. Since we used to navigate directly to the page that was "next at the time of clicking the button", we would then potentially try to navigate to a page that was no longer visible. So I made some changes in useNavigatePage so that we always use the "current" next page there, and now use navigateToNextPage in the navigation buttons instead. I did a similar thing to the NavigationBar

Screen.Recording.2025-02-05.at.11.53.40.mov

I then had some issues with autoSaveBehavior: onChangePage. This used to be just "fire and forget", but now I wait until we don't have any unsaved changes here as well. Since this does not auto save, I had to make sure we keep requesting a manual save if there are new changes that need to be saved, or the waitForSave could get stuck since a new save does not get triggered automatically.

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

@bjosttveit bjosttveit added the kind/bug Something isn't working label Feb 5, 2025
@bjosttveit bjosttveit changed the title improve how we navigate to next page etc Fix page navigation when using returnUrl Feb 5, 2025
Copy link
Contributor

@adamhaeger adamhaeger left a comment

Choose a reason for hiding this comment

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

Jeg er litt i tvil her. Funksjonaliteten er jo absolutt en forbedring, men det blir jo mye kompleks kode for å gjøre en relativt enkel ting.

Godkjenner PRen siden dette nok følger av strukturen i appen ellers, men viktig å se på arkitekturen rundt dette snart.

@bjosttveit
Copy link
Member Author

/publish

Copy link
Contributor

github-actions bot commented Feb 6, 2025

PR release:

  • <link rel="stylesheet" type="text/css" href="https://altinncdn.no/toolkits/altinn-app-frontend/4.16.0-pr.468.next-page-navigation.413fa8f9/altinn-app-frontend.css">
  • <script src="https://altinncdn.no/toolkits/altinn-app-frontend/4.16.0-pr.468.next-page-navigation.413fa8f9/altinn-app-frontend.js"></script>

⚙️ Building...
✅ Done!

@bjosttveit bjosttveit merged commit 8e7604c into main Feb 10, 2025
15 checks passed
@bjosttveit bjosttveit deleted the fix/next-page-navigation branch February 10, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Action-knapp, automatisk navigering tilbake til første side
3 participants