feat: lineHeight support for EnrichedText - #724
Open
kacperzolkiewski wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds lineHeight support to the native EnrichedText component so that style={{ lineHeight: ... }} influences both rendering and measurement on iOS/Android (web already has support via CSS conversion).
Changes:
- Extend the
EnrichedTextViewnative prop surface to includelineHeight(codegen spec + platform bindings). - Apply
lineHeightin iOS config updates and Android rendering (EnrichedTextView) + measurement (MeasurementStore). - Include
lineHeightin Android new-architecture prop serialization for measurement.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/spec/EnrichedTextNativeComponent.ts | Adds lineHeight to the native prop spec for EnrichedText. |
| ios/EnrichedTextView.mm | Applies lineHeight via EnrichedConfig during prop updates. |
| android/src/main/new_arch/react/renderer/components/ReactNativeEnrichedSpec/conversions.h | Serializes lineHeight for Fabric measurement. |
| android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedLineHeightSpan.kt | Changes how the line-height span behaves (notably for headings). |
| android/src/main/java/com/swmansion/enriched/text/MeasurementStore.kt | Incorporates lineHeight into Android text measurement by applying the span. |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextViewManager.kt | Exposes setLineHeight to the native view manager. |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt | Applies/removes the line-height span when props/state change. |
Comments suppressed due to low confidence (1)
android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedLineHeightSpan.kt:36
- This change removes the previous guard that prevented EnrichedLineHeightSpan from affecting heading paragraphs (EnrichedHeadingSpan). Since this span is also used by EnrichedTextInput, this is a behavior change that will start applying
lineHeightto headings in the input as well. If headings are still intended to keep their own metrics, reintroduce the heading check before applying the extra line height.
val lineHeightPx = pixelFromSpOrDp(lineHeight, allowFontScaling)
val currentHeight = (fm.descent - fm.ascent).toFloat()
if (lineHeightPx <= currentHeight) return
val extra = (lineHeightPx - currentHeight).toInt()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hejsztynx
approved these changes
Jul 27, 2026
| } | ||
|
|
||
| fun setLineHeight(height: Float) { | ||
| lineHeight = if (height == 0f) null else height |
Collaborator
There was a problem hiding this comment.
Suggested change
| lineHeight = if (height == 0f) null else height | |
| lineHeight = if (height <= 0f) null else height |
Collaborator
There was a problem hiding this comment.
Also I've noticed the same change would be applicable in EnrichedTextInputView.kt
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.
Summary
Fixes: #608
Add support for
lineHeighton mobile.On web It is already supported.
Test Plan
EnrichedTextlineHeightin style prop forEnrichedTextlineHeightshould be applied properlyScreenshots / Videos
Compatibility
Checklist