Skip to content

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented Oct 7, 2025

Description

In tablet mode, there was no way to scroll if the navigation popover exceeded the page height. This limits the height of the container to the available screen height and adds internal scrolling.

Testing for this will arrive in #3624, as one test there has been failing because the element is not reachable.

Before:

2025-10-07_14-19-45.mp4

After:

2025-10-07_14-18-36.mp4

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/* and backport* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Summary by CodeRabbit

  • New Features

    • Page navigation dropdown now dynamically limits its height to the visible viewport and becomes scrollable when needed, improving usability across screen sizes and preventing content overflow.
  • Chores

    • Version bumped to 15.3.0.

@olemartinorg olemartinorg added kind/bug Something isn't working backport-ignore This PR is a new feature and should not be cherry-picked onto release branches labels Oct 7, 2025
Copy link

coderabbitai bot commented Oct 7, 2025

📝 Walkthrough

Walkthrough

Updated snapshot version and added an internal hook in PopoverNavigation.tsx that computes and applies a dynamic maxHeight with overflow for the dropdown using ResizeObserver plus window resize/scroll listeners; wired via a ref and inline style. No public API changes.

Changes

Cohort / File(s) Summary
Version update
snapshots.js
Updated module.exports.__version from "15.2.0" to "15.3.0".
Navigation dropdown dynamic height
src/features/navigation/PopoverNavigation.tsx
Added useDynamicHeight hook (uses ResizeObserver and window resize/scroll listeners) to compute a maxHeight (minimum 200px) and overflowY: auto; introduced dropdownRef and applied returned style to the Dropdown element when rendered. No exported signatures changed.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The update to the snapshots.js file solely increments the __version value and is not related to the navigation popover height constraints or scrolling behavior defined in the linked issue, constituting an out-of-scope change. Please remove the version bump from snapshots.js or move it to a separate version-bump PR to keep this change focused on the popover scrolling feature.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the main change by specifying that dynamic height with overflow and scrolling has been added to the PopoverNavigation component, matching the core functionality implemented in the PR without extraneous detail.
Linked Issues Check ✅ Passed The changes introduce constraints on the popover container height and enable internal scrolling via the useDynamicHeight hook, directly addressing the missing scroll behavior described in issue #16369 by ensuring long navigation lists remain accessible within the viewport.
Description Check ✅ Passed The pull request description follows the repository template by providing a detailed description, clearly listing related issues, and filling out the Verification/QA checklist with appropriate selections for manual, automated, accessibility, documentation, support, sprint, and label checks.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/navigation-vertical-scroll

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/features/navigation/PopoverNavigation.tsx (1)

125-125: Simplify the type annotation.

React.RefObject<HTMLDivElement | null> is redundant since RefObject<T> already permits .current to be null.

Apply this diff:

-function useDynamicHeight(elementRef: React.RefObject<HTMLDivElement | null>, isActive: boolean): CSSProperties {
+function useDynamicHeight(elementRef: React.RefObject<HTMLDivElement>, isActive: boolean): CSSProperties {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e9f231 and 3d00556.

📒 Files selected for processing (2)
  • snapshots.js (1 hunks)
  • src/features/navigation/PopoverNavigation.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • src/features/navigation/PopoverNavigation.tsx
🧬 Code graph analysis (1)
src/features/navigation/PopoverNavigation.tsx (1)
src/hooks/useDeviceWidths.ts (1)
  • useIsMobile (21-23)
🔇 Additional comments (4)
snapshots.js (1)

370-370: LGTM!

Version bump is appropriate for this release.

src/features/navigation/PopoverNavigation.tsx (3)

1-2: LGTM!

The CSSProperties import is correctly added for typing the hook's return value.


31-33: LGTM!

The dropdownRef and dropdownStyle are correctly implemented to enable dynamic height management for the non-mobile dropdown.


62-71: LGTM!

The ref and style props are correctly wired to the Dropdown component, enabling the dynamic height constraint.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/navigation/PopoverNavigation.tsx (1)

93-93: Fix data attribute typo (daata-color).

Prevents intended styling.

-        daata-color='accent'
+        data-color='accent'
🧹 Nitpick comments (2)
src/features/navigation/PopoverNavigation.tsx (2)

148-155: Use passive scroll listener to reduce main-thread work.

Scrolling fires frequently; use passive: true with capture. Keep cleanup matching capture.

-    window.addEventListener('resize', updateMaxHeight);
-    window.addEventListener('scroll', updateMaxHeight, true);
+    window.addEventListener('resize', updateMaxHeight);
+    window.addEventListener('scroll', updateMaxHeight, { capture: true, passive: true });
@@
-      window.removeEventListener('resize', updateMaxHeight);
-      window.removeEventListener('scroll', updateMaxHeight, true);
+      window.removeEventListener('resize', updateMaxHeight);
+      window.removeEventListener('scroll', updateMaxHeight, { capture: true });

158-159: Optional: Only set overflow when constrained.

Avoids unnecessary styling when not open/active.

-  return { maxHeight: maxHeight ? `${maxHeight}px` : undefined, overflowY: 'auto' };
+  return {
+    maxHeight: maxHeight !== undefined ? `${maxHeight}px` : undefined,
+    overflowY: maxHeight !== undefined ? 'auto' : undefined,
+  };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d00556 and 8d99af1.

📒 Files selected for processing (1)
  • src/features/navigation/PopoverNavigation.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • src/features/navigation/PopoverNavigation.tsx
🧬 Code graph analysis (1)
src/features/navigation/PopoverNavigation.tsx (1)
src/hooks/useDeviceWidths.ts (1)
  • useIsMobile (21-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Install
  • GitHub Check: Type-checks, eslint, unit tests and SonarCloud
  • GitHub Check: Analyze (javascript)

Copy link

sonarqubecloud bot commented Oct 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 45%)
0.0% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/features/navigation/PopoverNavigation.tsx (1)

93-96: Typo in attribute name.

Change daata-color to data-color.

-        daata-color='accent'
+        data-color='accent'
♻️ Duplicate comments (1)
src/features/navigation/PopoverNavigation.tsx (1)

141-146: Initial measurement call looks good.

Calling updateMaxHeight immediately prevents initial overflow/flicker.

🧹 Nitpick comments (1)
src/features/navigation/PopoverNavigation.tsx (1)

148-155: Use passive scroll listeners and consistent options.

Avoids main-thread jank on scroll and ensures symmetric add/remove.

-    window.addEventListener('resize', updateMaxHeight);
-    window.addEventListener('scroll', updateMaxHeight, true);
+    const listenerOptions = { capture: true, passive: true } as const;
+    window.addEventListener('resize', updateMaxHeight, listenerOptions);
+    window.addEventListener('scroll', updateMaxHeight, listenerOptions);
...
-      window.removeEventListener('resize', updateMaxHeight);
-      window.removeEventListener('scroll', updateMaxHeight, true);
+      window.removeEventListener('resize', updateMaxHeight, listenerOptions);
+      window.removeEventListener('scroll', updateMaxHeight, listenerOptions);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d99af1 and 88714f1.

📒 Files selected for processing (1)
  • src/features/navigation/PopoverNavigation.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid using any and unnecessary type casts (as Type) in TypeScript; prefer precise typings and refactor existing casts/anys
For TanStack Query, use objects to manage query keys and functions, and centralize shared options via queryOptions

Files:

  • src/features/navigation/PopoverNavigation.tsx
🧬 Code graph analysis (1)
src/features/navigation/PopoverNavigation.tsx (1)
src/hooks/useDeviceWidths.ts (1)
  • useIsMobile (21-23)
🔇 Additional comments (2)
src/features/navigation/PopoverNavigation.tsx (2)

31-34: Good gating and wiring of dynamic height.

Using a ref and enabling the hook only when open and non‑mobile is correct.


63-71: Ref + inline style applied correctly.

Passing ref to Dropdown and applying computed style is appropriate.

@olemartinorg olemartinorg merged commit 58d0247 into main Oct 7, 2025
14 of 16 checks passed
@olemartinorg olemartinorg deleted the bug/navigation-vertical-scroll branch October 7, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-ignore This PR is a new feature and should not be cherry-picked onto release branches kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing scroll in navigation component

2 participants