Repository navigation
Commit 103d780
authored
Fix multiline EditableText selection highlighting width (flutter#185239)
## Description
This PR fixes multiline text selection highlighting that can incorrectly
include trailing whitespace width from another line.
<img width="500" height="1100" alt="Screenshot_1776501043"
src="https://github.com/user-attachments/assets/9cff38f7-86fc-447b-8026-c419c5de36af"
/>
In `EditableText`, the default `defaultSelectionWidthStyle` now returns
`BoxWidthStyle.tight` always
This prevents multiline selections from being visually extended to match
other line widths (the behavior reported in the issue), while preserving
current single-line behavior and honoring explicit `selectionWidthStyle`
overrides.
## Fixed issue
Fixes flutter#174689
Fixes flutter#180311
## Tests
Added widget tests in
`packages/flutter/test/widgets/editable_text_test.dart`:
- `EditableText uses tight selection width style by default for
multiline`
- `Explicit selectionWidthStyle is honored for multiline EditableText`
Locally verified:
- `flutter test packages/flutter/test/widgets/editable_text_test.dart
--plain-name "selection width style"`
- `flutter test packages/flutter/test/material/text_field_test.dart
--plain-name "text selection style"`
- `flutter analyze packages/flutter/lib/src/widgets/editable_text.dart
packages/flutter/test/widgets/editable_text_test.dart`1 parent 0c29588 commit 103d780
5 files changed
Lines changed: 85 additions & 41 deletions
File tree
- packages/flutter
- lib/src
- rendering
- widgets
- test/widgets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
| 599 | + | |
| 600 | + | |
599 | 601 | | |
600 | 602 | | |
601 | 603 | | |
| |||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
| |||
2155 | 2153 | | |
2156 | 2154 | | |
2157 | 2155 | | |
2158 | | - | |
2159 | | - | |
2160 | | - | |
2161 | | - | |
2162 | | - | |
2163 | | - | |
2164 | | - | |
2165 | | - | |
2166 | | - | |
2167 | | - | |
2168 | | - | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
| 2156 | + | |
| 2157 | + | |
2173 | 2158 | | |
2174 | 2159 | | |
2175 | 2160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
297 | 377 | | |
298 | 378 | | |
299 | 379 | | |
| |||
0 commit comments