Conversation
…ions in MissionVision component
refactor: improve code readability by formatting line height calculat…
There was a problem hiding this comment.
Pull request overview
This PR updates the MissionVision About page component, primarily adjusting how the computed lineHeight call is formatted within the truncation measurement effect.
Changes:
- Reformats
parseInt(getComputedStyle(...).lineHeight)into a multi-line call for both mission and vision truncation checks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| const lineHeight = parseInt( | ||
| getComputedStyle(missionRef.current).lineHeight, | ||
| ); | ||
| const maxHeight = lineHeight * 5; | ||
| setMissionNeedsTruncate(missionRef.current.scrollHeight > maxHeight); |
There was a problem hiding this comment.
parseInt(getComputedStyle(...).lineHeight) is brittle here: lineHeight can be a non-integer (or even 'normal'), and parseInt truncates decimals / can yield NaN. Consider using Number.parseFloat(...) (and/or a safe fallback) and explicitly handle non-numeric values to avoid incorrect maxHeight calculations.
| getComputedStyle(visionRef.current).lineHeight, | ||
| ); | ||
| const maxHeight = lineHeight * 5; | ||
| setVisionNeedsTruncate(visionRef.current.scrollHeight > maxHeight); | ||
| } |
There was a problem hiding this comment.
maxHeight is calculated as lineHeight * 5, but the UI applies line-clamp-6 when truncating. This mismatch can cause missionNeedsTruncate / visionNeedsTruncate to be true (and show the "See more" button) even when the text wouldn’t actually be clamped. Align the multiplier with the clamp line count (or derive both from a shared constant).
No description provided.