DEV: Prevent static viewport header link initialization#48
Merged
Conversation
…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.
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.
tyb-talks
approved these changes
Sep 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates header icon link initialization logic to avoid accessing static viewport modes during setup.