fix comments in feat/16446-navigation-validation#4094
fix comments in feat/16446-navigation-validation#4094walldenfilippa merged 3 commits intofeat/16446-navigation-validationfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Magnusrm
left a comment
There was a problem hiding this comment.
Great work! 🎉
Just a minor nitpick below
| if (isCurrentPage || !currentPageId) { | ||
| return; | ||
| } | ||
|
|
||
| const currentIndex = order.indexOf(currentPageId); | ||
| const targetIndex = order.indexOf(page); | ||
| if (currentIndex === -1 || targetIndex === -1) { | ||
| return; | ||
| } | ||
|
|
||
| const isForward = targetIndex > currentIndex; | ||
| const validationOnNavigation = getPageValidation(); | ||
|
|
||
| await maybeSaveOnPageChange(); | ||
|
|
||
| if (isForward && validationOnNavigation) { | ||
| const hasValidationErrors = await onPageNavigationValidation(currentPageId, validationOnNavigation); | ||
| if (hasValidationErrors) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| await navigateToPage(page); | ||
| onNavigate?.(); |
There was a problem hiding this comment.
Nitpick: I think it would be neater to extract this code into a function instead of directly in the onClick.
|
84d3491
into
feat/16446-navigation-validation
* #17511 + #17512 (#3977) Co-authored-by: walldenfilippa <filippa.walden@digdir.no> * Override validation on navigationbuttons * minor clean up * added override validation on the navigationBar component * added ovverride customButton + configured the validateOnNext/Forward and validateOnPrevious/Backward with preventNavigation prop for validationOnNavigation * Feat/prevent-navigation (#3990) * add basic logic for preventing navigation * change wording * added PageValidation on layoutSets and layoutSettings (#3998) * added PageValidation on layoutSets and layoutSettings --------- Co-authored-by: walldenfilippa <filippa.walden@digdir.no> * Feat/refactor pagevalidation navigation (#4005) * refactor: navigation validation backward and improve page validation hooks * refactor preventing navigation to use simplified config --------- Co-authored-by: walldenfilippa <filippa.walden@digdir.no> Co-authored-by: Magnus Revheim Martinsen <mrmartinsen.96@gmail.com> * added prop expandedByDefault to groups for sidenavigation (#4006) * added prop expandedByDefault to groups for sidenavigation * added prop expandedByDefault to subform sidenavigation --------- Co-authored-by: walldenfilippa <filippa.walden@digdir.no> * Updated the validation hierarchy for the navigation rules. * fix prevent navigation * feat: enhance navigation validation by integrating validation checks (#4027) * feat: enhance navigation validation by integrating validation checks in navigation components * removed one hook and added useGetNavigationIsPrevented on pageGroup aswell * temporary notes * remove temporary note * update tests --------- Co-authored-by: walldenfilippa <filippa.walden@digdir.no> * merge main into feat/16446-navigation-validation * changed ovverride level direction on validation on navigation and moved validationOnNavigation to GlobalPageSettings (#4064) Co-authored-by: walldenfilippa <filippa.walden@digdir.no> * fix comments in feat/16446-navigation-validation (#4094) * fix comments in feat/16446-navigation-validation * fixed tests in NavigationButtons tests * refactor: implement navigation with validation logic in Page and PageGroup components --------- Co-authored-by: walldenfilippa <filippa.walden@digdir.no> --------- Co-authored-by: Filippa Wallden <143729834+walldenfilippa@users.noreply.github.com> Co-authored-by: walldenfilippa <filippa.walden@digdir.no>



Description
Fix comments:



1.
PageGroupMultipledelegates toPage.tsxfor each entry, which already handles validation.PageGroupSinglerenders its own button directly and therefore did not inherit that logic.2.
Always render the toggle button so the section can be collapsed, and auto-expand it when the user is on the current page, consistent with how
PageGroupMultiplebehaves.3.
Fixed flaky tests
Related Issue(s)
Verification/QA
kind/*andbackport*label to this PR for proper release notes grouping