Skip to content

Conversation

@megothss
Copy link
Contributor

@megothss megothss commented Sep 15, 2025

This PR updates header icon link initialization logic to avoid accessing static viewport modes during setup.

  • Refactors header link rendering to check viewport mode conditionally
  • Improves reliability by preventing premature or invalid static viewport access

…ation

Refactor header icon links to dynamically determine `site.mobileView`. This ensures conditional rendering based
on the current viewport state while avoiding premature static lookups.

Improves robustness in customizing header icons for mobile and desktop
layouts.
Rename `buildIcon` to `buildIconTemplate` for clarity and refactor width
parsing to use `Number.isFinite` for safer checks. Streamline conditional
rendering logic for mobile and desktop views, improving code maintainability.
@megothss megothss changed the title DEV: Prevent static viewport mode access during header link initialization DEV: Prevent static viewport header link initialization Sep 15, 2025
Move `isLastLink` logic to a method using `site.mobileView` service for
dynamic checks of visible links. This replaces static index comparisons
with runtime filtering, ensuring accurate detection in both mobile and
desktop views.

Improves maintainability and correctness of conditional styling for the
last custom header icon link.
Refactor header icon link initialization by delegating rendering logic to a new `CustomHeaderIcon` component. This modularizes `isLastLink`, styling, and rendering logic, improving maintainability and separation of concerns.
Refactor `shouldRender` and `isLastLink` logic by introducing a reusable
`shouldRenderViewMode` function and encapsulating mobile/desktop view
checks in dedicated sets. Extract `visibleLinks` computation into a
separate getter for clarity and reuse.
@megothss megothss merged commit 8580e59 into main Sep 16, 2025
5 checks passed
@megothss megothss deleted the dev/prevent-static-viewport branch September 16, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants