Skip to content

fix: bug fix that caused the input field to hide out#158

Merged
nikilok merged 5 commits into
mainfrom
fix/bug-input-hides
Jun 9, 2026
Merged

fix: bug fix that caused the input field to hide out#158
nikilok merged 5 commits into
mainfrom
fix/bug-input-hides

Conversation

@nikilok

@nikilok nikilok commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved scroll position persistence to only save when scrolled down (Y > 0), preventing search input from being unnecessarily hidden when the page is at the top.
    • Fixed search input visibility logic to properly restore based on valid scroll positions and prevent permanent hiding in certain edge cases.

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
learn-tanstack-start Ready Ready Preview, Comment Jun 9, 2026 3:58pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@nikilok, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 2 minutes and 12 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 343814bf-c73c-43d0-bfc2-2bdd24303ded

📥 Commits

Reviewing files that changed from the base of the PR and between 1cbad59 and f91cf86.

📒 Files selected for processing (5)
  • CLAUDE.md
  • apps/web/src/components/HmrcCard.tsx
  • apps/web/src/components/HmrcResults.tsx
  • apps/web/src/hooks/useSearchPill.ts
  • apps/web/src/scripts/search-input-init.ts
📝 Walkthrough

Walkthrough

This PR fixes the scroll-restoration mechanism by enforcing that only positive Y values trigger hiding and restoring the search input. Pre-hydration now validates parsed values, writers only persist when scrollY > 0, and cleanup removes stale keys when restore is impossible.

Changes

Scroll-y restore invariants and cleanup

Layer / File(s) Summary
Scroll-y sessionStorage invariants documentation
CLAUDE.md
Specifies that hmrc-scroll-y must represent Y > 0, documents how HmrcCard and pre-hydration conditionally persist/stamp based on positive values, and describes HmrcResults cleanup guard logic.
Pre-hydration validation for hide attribute stamping
apps/web/src/scripts/search-input-init.ts
Pre-hydration now parses hmrc-scroll-y and only stamps data-hide-search-input when the value is a positive integer, replacing the prior existence check.
Conditional scroll persistence in HmrcCard
apps/web/src/components/HmrcCard.tsx
Click handler writes window.scrollY to sessionStorage only when scrollY > 0; otherwise removes the key to prevent zero values from persisting.
Cleanup of stale scroll-y on non-restoring mounts
apps/web/src/components/HmrcResults.tsx
New useEffect removes hmrc-scroll-y when restore is not possible (search < 3 chars or no loading/results), preventing stale keys from hiding the input on later loads.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • nikilok/learn-tanstack-start#40: Both PRs modify hmrc-scroll-y sessionStorage handling in HmrcResults.tsx and the scroll-state persistence mechanism.
  • nikilok/learn-tanstack-start#36: Both PRs adjust the pre-hydration script and scroll-restoration flow in search-input-init.ts to control when the search input is hidden/restored based on scroll position.

Poem

🐰 A scroll position saved with care,
Must be positive, true and fair,
No zeros hiding what should show,
Cleanup sweeps the stale below,
Restored or fresh, the flow runs clear! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: preventing the search input field from being hidden when it shouldn't be, which is addressed across multiple files by validating scrollY values and cleaning up stale sessionStorage keys.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bug-input-hides

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.

@nikilok nikilok merged commit 754b971 into main Jun 9, 2026
5 checks passed
@nikilok nikilok deleted the fix/bug-input-hides branch June 9, 2026 16:07
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.

1 participant