feat(web): ellipsizeMode and numberOfLines in EnrichedText#687
Open
hejsztynx wants to merge 14 commits into
Open
feat(web): ellipsizeMode and numberOfLines in EnrichedText#687hejsztynx wants to merge 14 commits into
hejsztynx wants to merge 14 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds web support for numberOfLines + ellipsizeMode on EnrichedText by computing a truncated HTML representation via DOM measurement in a hidden sandbox, plus documentation and E2E visual coverage.
Changes:
- Integrates
ellipsizeMode/numberOfLinesintosrc/web/EnrichedText.tsxvia a newuseEllipsizeModehook. - Introduces web ellipsize implementations (
head,middle,tail,clip) built on shared DOM utilities. - Adds a new example web test screen + Playwright visual regression suite and updates docs to reflect web support.
Reviewed changes
Copilot reviewed 14 out of 89 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/web/EnrichedText.tsx | Wires ellipsizeMode + numberOfLines into the web component and renders clamped HTML. |
| src/web/ellipsizeMode/utils.ts | Shared sandbox creation + DOM walking/trimming helpers used by all ellipsize modes. |
| src/web/ellipsizeMode/useEllipsizeMode.ts | Hook that selects and runs the appropriate ellipsize algorithm in useLayoutEffect. |
| src/web/ellipsizeMode/tailEllipsize.ts | Tail ellipsis implementation (“…at end”) using scan + backward trimming. |
| src/web/ellipsizeMode/headEllipsize.ts | Head ellipsis implementation (“…at start”) using scan + forward trimming. |
| src/web/ellipsizeMode/middleEllipsize.ts | Middle ellipsis implementation with center-point placement and head fallback logic. |
| src/web/ellipsizeMode/clip.ts | Clip implementation (hard cut without ellipsis). |
| src/index.tsx | Exports EnrichedTextProps type from the package entry. |
| docs/WEB.md | Documents that web EnrichedText now supports truncation props. |
| docs/TEXT_API_REFERENCE.md | Updates API reference tables to include Web platform support for truncation props. |
| apps/example-web/src/testScreens/TestEllipsize.tsx | Adds a UI harness for exercising ellipsize behaviors in the example web app. |
| apps/example-web/src/RouteSelector.tsx | Adds routing for the new /test-ellipsize screen. |
| apps/example-web/src/App.tsx | Temporarily modified example app to make manual testing easier (needs cleanup before merge). |
| .playwright/tests/ellipsizeVisual.spec.ts | Adds visual regression coverage for multiple ellipsize modes and edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Base automatically changed from
@ksienkiewicz/fix-web-list-wrapping-display
to
main
July 8, 2026 14:40
5e77e06 to
e6aceb1
Compare
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
Implemented
ellipsizeModeandnumberOfLinesprops inEnrichedTextweb component.The RN
ellipsizeModecan often cause confusion, as it only works when the ellipsized text is a continuous text that wraps the lines. If try to ellipsize text that consists of paragraphs, theellipsizeModebails, often just showing the givennumberOfLineslimit without actually rendering the ellipsis, which is pretty confusing. The web's DOM allows us to compute the text truncation more precisely and here it does so.tail,head,middle,clipare implementedmiddleworks a bit differently, as we can't really merge two different paragraph styles into one line, so if such situation occurs, we fallback to theheadbehavioruseLayoutEffectTest Plan
I've modified example app's code so it's easier to test repeatedly - the changes are marked with a
//comment, and will be removed before the merge:EnrichedText, but withoutnumberOfLinesset to see how would it render without the ellipsizing,Play around with the modes, make sure the HTML is computed and rendered as expected. Inline images, line brakes, long words were often something that would brake the algorithm, so try working with that.
Screenshots / Videos
Compatibility
Checklist