mWeb - Multiline Text
's clipped part is scrolled into view by dragging selection cursor
#2582
Open
1 task done
Labels
Is there an existing issue for this?
Describe the issue
Text
component withnumberOfLines
is truncated with ellipsis. However:numberOfLines > 1
;then:
Sandbox: https://codesandbox.io/s/vigorous-yalow-sjf2yr
Demo: https://sjf2yr.csb.app/
Screenshots
Reproduce on mobile Chrome, please refer to Steps to reproduce section:
Screenrecording_20230923_004840.mp4
The text is truncated with ellipsis:
But we can scroll through out the clipped text:
The ellipsis remains at the initial position:
Expected behavior
The
Text
if truncated should completely be hidden/clipped and not be selected by any means of scroll.Steps to reproduce
Reproduced on mobile Chrome.
Text
withnumberOfLines > 1
Test case
https://codesandbox.io/s/vigorous-yalow-sjf2yr
Additional comments
My proposed solution:
What is the root cause of that problem?
When
numberOfLines
is1
, it uses automatic ellipsis withtext-overflow: ellipsis
WhennumberOfLines
is larger than1
, it uses fragmenting overflow with-webkit-line-clamp
andoverflow: hidden
.react-native-web/packages/react-native-web/src/exports/Text/index.js
Lines 219 to 225 in a3ea2a0
The problem with
-webkit-line-clamp
is that it does not actually "truncate" the text but inserts an ellipsis in the last position of the specified line (reference). That explains why the ellipsis always stays at the same position. We could easily see that the whole text was still there by using DevTools to inspect the div.Although
overflow: hidden
prevents scrolling interface, the wrapper box is still a scroll container and it still allows programmatic scrolling. I think that the dragging cursor to select text in Chrome is somehow related to these two cases.What changes do you think we should make in order to solve the problem?
Use
overflow: clip
instead ofoverflow: hidden
intextMultiline
style to "forbid scrolling entirely, through any mechanism" as mentioned in the document here.The text was updated successfully, but these errors were encountered: