Skip to content

Text highlighting/selection issue with Flutter 3.27.2 on Web #2450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
bloemy7 opened this issue Jan 22, 2025 · 70 comments
Open
1 task done

Text highlighting/selection issue with Flutter 3.27.2 on Web #2450

bloemy7 opened this issue Jan 22, 2025 · 70 comments
Labels
blocked This issue cannot be resolved due to an obstacle or dependency. bug Something isn't working critical Requires immediate attention. This issue causes major functionality loss, crashes, or security vulne external issue This issue is caused by an external dependency and cannot be resolved within this project. help wanted Extra attention is needed reproducible This bug has been confirmed and can be reliably reproduced. web Issues or feature requests specific to the Web platform.

Comments

@bloemy7
Copy link

bloemy7 commented Jan 22, 2025

Have you checked for an existing issue?

Flutter Quill Version

10.8.5

Steps to Reproduce

  1. Setup project with flutter-quill when running flutter version 3.27.2
  2. Try highlighting text to select it

Expected results

Expecting to be able to smoothly select text

Actual results

Almost impossible to select text as it auto-select multiple lines in a very buggy way

Additional Context

The issue seems to be around the precision of the cursor when selecting a line. If you put it exactly at the height of a line, it acts as if it was already slightly above the line, and so it automatically selects the full line. This makes the entire experience impossible to properly control.

I have downgraded Flutter to 3.27.1 and 3.27.0, but there when selecting text it doesn't show the resulting highlight as you are dragging, only once you release the drag, which is not a good experience either.

Any ideas?

@bloemy7 bloemy7 added the bug Something isn't working label Jan 22, 2025
@EchoEllet
Copy link
Collaborator

10.8.5

Could you try with 11.0.0-dev.20 (or later) as the magnifier has been removed and related issues have been fixed.

@bloemy7
Copy link
Author

bloemy7 commented Jan 22, 2025

Hi @EchoEllet, just tried with 11.0.0-dev.21, and it's still happening for me unfortunately.

Screen.Recording.2025-01-21.at.10.29.06.PM.mov

Any other ideas? Thanks!

@EchoEllet
Copy link
Collaborator

Is this issue encounterable on Android and iOS, or is this a desktop specific issue?

@bloemy7
Copy link
Author

bloemy7 commented Jan 22, 2025

For now we have only seen it on web but I have not tried on the native apps yet, I can get you that information tomorrow.

The main problem we have is that we have the Flutter bug with iOS 18.2 which means that scrolling on iOS web does not work since we still run Flutter 24, but upgrading to 27 causes this issue so I’m stuck in between both. Any help would be amazing!

@jonasbernardo
Copy link

I tested it here, on Android the selection with a bluetooth mouse works normally, the problem only happens in the web version, another problem is also when clicking on empty lines, the cursor always appears on the top line and not on the clicked line, but it needs to be between two text when there is an empty space

@jonasbernardo

This comment has been minimized.

@jonasbernardo

This comment has been minimized.

@EchoEllet
Copy link
Collaborator

The main problem we have is that we have the Flutter bug with iOS 18.2 which means that scrolling on iOS web does not work since we still run Flutter 24

Is this a different issue than the text selection?

@bloemy7
Copy link
Author

bloemy7 commented Jan 24, 2025

Yes that is a separate bug that is not related to flutter-quill at all, sorry for the confusion here. But it's a bug that forces us to update Flutter version, except that we cannot because of this bug @EchoEllet .

@CatHood0
Copy link
Collaborator

CatHood0 commented Jan 26, 2025

I cannot reproduce this issue in Flutter 3.27.3 and the package version 11.0.0-dev.20

@bloemy7

This comment has been minimized.

@jonasbernardo
Copy link

yes, the problem persisted, I recorded a video running the example within the flutter quill package
@CatHood0
@bloemy7
@EchoEllet

bug-selecao.mp4

@jonasbernardo

This comment has been minimized.

@jonasbernardo

This comment has been minimized.

@bloemy7

This comment has been minimized.

@EchoEllet

This comment has been minimized.

@Heyholder
Copy link

i have same issue. did you fix it?

2025-02-13.1.46.04.mov

@bloemy7
Copy link
Author

bloemy7 commented Feb 13, 2025

I just tried with the latest Flutter 3.29.0 stable release and unfortunately this still reproduces. @CatHood0 are you maybe able to reproduce? Can this get investigated in some way? I'm happy to help contribute but not quite sure where to start on this issue.
This is causing major issue in production apps and seems to be widely reproducible on very basic configurations.

Thanks a lot.

@jonasbernardo

This comment has been minimized.

@jonasbernardo
Copy link

jonasbernardo commented Feb 13, 2025

@bloemy7
@CatHood0
@EchoEllet
new information, the problem does not happen if you are using mozilla firefox or the latest version of google chrome

@realth000
Copy link
Contributor

Is this the same issue in flutter dev tools?

For example, in dev tools -> network -> select a request -> goto the Response tab on the right side, select some text and a similar issue occurs if the text is multi line.

  • Flutter 3.29.0, Chrome on Windows.

@jonasbernardo
Copy link

update from my latest tests: text selection only works in mozilla firefox

@dominikkeller
Copy link

I am experiencing the same issue in all browsers except Safari and Firefox.
This is a significant issue for our application.

Flutter version: 3.27.2.

@hannutho
Copy link

@jonasbernardo
@bloemy7
@CatHood0
@EchoEllet
Safari on Mac also works.
Anyone found any workaround or fix for this?

@RJustoX
Copy link

RJustoX commented Feb 18, 2025

Hi everyone, I'm encountering the same issue.

I noticed that adding the following code:

customStyles: DefaultStyles(
  paragraph: DefaultTextBlockStyle(
    // your textStyle
    const HorizontalSpacing(4, 4),
    const VerticalSpacing(4, 4),
    const VerticalSpacing(4, 4),
    null,
  ),
),

is causing the selection to extend four lines above the text I want to select. Without this, it only selects the line I want plus one. Has anyone else experienced this?

flutter 3.27.3 | quill 11.0.0 | testing on chrome

@bloemy7
Copy link
Author

bloemy7 commented Feb 18, 2025

@CatHood0 it seems like this issue is becoming more widespread and probably should be more thoroughly investigated at this point as it makes the editor as such unusable. If anyone has any thoughts on how to proceed here it would be great...

@Heyholder
Copy link

Heyholder commented Feb 18, 2025

below is my quillEditor setting.

final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context);
    const HorizontalSpacing baseHorizontalSpacing = HorizontalSpacing(0, 0);
    const VerticalSpacing baseVerticalSpacing = VerticalSpacing(0, 12);
    return QuillEditor.basic(
      controller: quillController,
      configurations: QuillEditorConfigurations(
        minHeight: minHeight,
        embedBuilders: FlutterQuillEmbeds.editorWebBuilders(),
        showCursor: showCursor,
        padding: const EdgeInsets.all(16),
        placeholder: hintText,
        enableSelectionToolbar: false,
        customStyles: DefaultStyles(
          h1: DefaultTextBlockStyle(
              defaultTextStyle.style.copyWith(
                  fontSize: 36, height: 1.65, fontWeight: FontWeight.w700),
              baseHorizontalSpacing,
              baseVerticalSpacing,
              VerticalSpacing.zero,
              null),
          h2: DefaultTextBlockStyle(
              TextStyle(
                fontSize: 24,
                height: 1.65,
                fontWeight: FontWeight.w600,
              ),
              baseHorizontalSpacing,
              baseVerticalSpacing,
              VerticalSpacing.zero,
              null),
          h3: DefaultTextBlockStyle(
              TextStyle(
                  height: 1.65, fontSize: 20, fontWeight: FontWeight.w600),
              baseHorizontalSpacing,
              baseVerticalSpacing,
              VerticalSpacing.zero,
              null),
          paragraph: DefaultTextBlockStyle(
              defaultTextStyle.style.copyWith(fontSize: 20, height: 1.65),
              baseHorizontalSpacing,
              baseVerticalSpacing,
              VerticalSpacing.zero,
              null),
          lists: DefaultListBlockStyle(
              TextStyle(fontSize: 20, height: 1.65),
              baseHorizontalSpacing,
              baseVerticalSpacing,
              VerticalSpacing.zero,
              null,
              null),
          sizeHuge: TextStyle(
            height: 1.65,
            fontSize: 24,
            fontWeight: FontWeight.w500,
          ),
        ),
      ),
    );

@dominikkeller
Copy link

dominikkeller commented Feb 18, 2025

@RJustoX
I experienced something similar. In my case, it was due to the editor’s padding. Without the padding, it would select the line I wanted plus one extra, but not as many as 4-5 lines.

Edit:
I removed all VerticalSpacing attributes or set them to 0 in my customSytles and with this the web editors work perfectly fine.
This is not really an option sadly as it makes the editor look bad.

@jonasbernardo
Copy link

@dominikkeller
In my case this didn't work, the problem persists even with zero vertical space

@jonasbernardo

This comment has been minimized.

@EchoEllet EchoEllet changed the title Text highlighting/selection issue with Flutter 3.27.2 Text highlighting/selection issue with Flutter 3.27.2 on Web Feb 24, 2025
@EchoEllet EchoEllet added web Issues or feature requests specific to the Web platform. reproducible This bug has been confirmed and can be reliably reproduced. help wanted Extra attention is needed and removed awaiting response Pending additional information or feedback from the issue creator labels Feb 24, 2025
@EchoEllet
Copy link
Collaborator

I can confirm the issue, reproduced on Google Chrome using Flutter stable 3.29.0 Dart 3.7.0.

WebBug.mov

@CatHood0

This comment has been minimized.

@RJustoX
Copy link

RJustoX commented Feb 24, 2025

I have this problem on windows 11

@ChiHoc
Copy link

ChiHoc commented Feb 28, 2025

For me, I encountered the same issue with Flutter's native TextField. When I tried replacing TextField with Quill, the problem still persisted. Maybe this issue is not related to Quill itself.

Flutter: 3.27.4
flutter_quill: 11.0.0-dev.20
Chrome: 133.0.6943.142(Stable) (arm64)
MacOS: 15.1

@GuillermoDLCO
Copy link

I also have same issue.

Flutter: 3.27.4
flutter_quill: 11.0.0-dev.21
MacOS: 15.3.1

@theAugur
Copy link

Just wanted to confirm that I´m having the same issue when using quill editor in chrome.. both in windows and android. Oddly enough this does not happen when using firefox on windows.

Flutter: 3.29.2
flutter_quill: flutter_quill: ^11.1.0

@jezell
Copy link
Collaborator

jezell commented Mar 23, 2025

Hey guys, put together a PR for tihs:

flutter/flutter#165732

Fixes an issue in the Flutter engine

@CatHood0
Copy link
Collaborator

I knew I wasn't crazy! But I really didn't know where the problem lay in Flutter (I don't quite understand the project structure). I'm glad you're getting it fixed. Thanks for taking the time to do this and let us know!

@jezell
Copy link
Collaborator

jezell commented Mar 23, 2025

Yeah you aren't crazy. It's impacting every editor and the core text fields. I've also seen impacting re_editor as well. Glad to help out. Seems to be a fairly widespread problem for anything editing text on web in the last few releases.

@EchoEllet EchoEllet added blocked This issue cannot be resolved due to an obstacle or dependency. external issue This issue is caused by an external dependency and cannot be resolved within this project. labels Mar 23, 2025
@aleripe
Copy link
Contributor

aleripe commented Mar 26, 2025

Hey guys, put together a PR for tihs:

flutter/flutter#165732

Fixes an issue in the Flutter engine

Unfortunately the fix doesn't work. Fixes the position while dragging, but makes it wrong when the mouse gets released...

@jezell
Copy link
Collaborator

jezell commented Mar 26, 2025

@aleripe I discovered the real problem was a bit deeper in the engine and also impacted scrollbars due to improper mouse pointer calculation.

If you are running Flutter 3.29.2 and want a patch so scrollbars and textboxes aren't screwed up. Replace your flutter_web_sdk in flutter/bin/cache with the one in here:

https://storage.googleapis.com/flutter-builds/releases/3.29.2/flutter_web_sdk.zip

Will push the patch to flock later this week. Let me know if you have issues with it. The mouse position is correct on drag and release. Also fixes the scrollbars.

@aleripe
Copy link
Contributor

aleripe commented Mar 26, 2025

@aleripe I discovered the real problem was a bit deeper in the engine and also impacted scrollbars due to improper mouse pointer calculation.

If you are running Flutter 3.29.2 and want a patch so scrollbars and textboxes aren't screwed up. Replace your flutter_web_sdk in flutter/bin/cache with the one in here:

https://storage.googleapis.com/flutter-builds/releases/3.29.2/flutter_web_sdk.zip

Will push the patch to flock later this week. Let me know if you have issues with it. The mouse position is correct on drag and release. Also fixes the scrollbars.

Thanks for your kind reply! I just tried your patch and it works, indeed.
I fully understand your frustration, but PLEASE don't give up on Flutter. Their team is not the best, but the whole community is :)

@jezell
Copy link
Collaborator

jezell commented Mar 26, 2025

Yeah not giving up on Flutter, just taking a different path. Anyone can always do a PR with any flock patch back to Flutter. I just would rather spend my time fixing things than fighting the system :)

@Demetriox

This comment has been minimized.

@marcio-ota

This comment has been minimized.

@andrescastane
Copy link

Any updates? Is there any Flutter version where this error doesn’t occur?

I've tested it with flutter_quill version 10.8.3, and the issue still persists, so it does seem very likely to be a Flutter engine issue as mentioned.
Also, everything works correctly on both Windows and macOS — I'm only experiencing this problem on Flutter Web.

If there’s a specific older version of Flutter where this bug doesn’t happen, I’d really appreciate knowing about it.

github-merge-queue bot pushed a commit to flutter/flutter that referenced this issue May 13, 2025
Fixes #167805
Fixes #162698

### Description

First of all, I would like to thank @jezell for posting their fix of
this selection issue:
singerdmx/flutter-quill#2450 (comment)

The issue with selection is happening because in Chrome `pointermove`
event and its coalesced events have some different targets. @mdebbar
already spotted this behavior some time ago and even filed a Chrome bug:
flutter/engine#56949 (comment)

This jsfiddle allows reproducing the bug:
https://jsfiddle.net/knevercode/y2hpfmrb/2/

On the following recording, you can see the events' targets and their
bounding boxes.
<video
src="https://github.com/user-attachments/assets/82af8d86-2cfe-4e36-a977-46ffa58facdb"/>

Those coalesced events have their `offsetX` and `offsetY` values
relative to the dummy `div` target. So to fix that, we have to translate
those values to be relative to the actual target.

This PR does exactly this in `_computeOffsetForInputs` when
`event.target != eventTarget` .

| Before | After |
| - | - |
| https://chrome-input-selection-bug.web.app |
https://chrome-input-selection-fix.web.app |
| <video
src="https://github.com/user-attachments/assets/1e10b43a-ff4f-46e8-8977-ee435f9d78fb"/>
| <video
src="https://github.com/user-attachments/assets/a997bfd0-8361-4bb3-910c-58cfc6b5d426"/>
|

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@BenDevExatech
Copy link

BenDevExatech commented May 21, 2025

Any updates? Is there any Flutter version where this error doesn’t occur?

I've tested it with flutter_quill version 10.8.3, and the issue still persists, so it does seem very likely to be a Flutter engine issue as mentioned. Also, everything works correctly on both Windows and macOS — I'm only experiencing this problem on Flutter Web.

If there’s a specific older version of Flutter where this bug doesn’t happen, I’d really appreciate knowing about it.

I'm facing the same issue, and I can confirm that it occurs specifically on Web with Chrome engine (on Edge and Opera too), but it's OK with Firefox and Safari, also OK on Desktop.

I've tried the current fix version here :
flutter/flutter#168217

Based on the last flutter_quill version 11.4.1 with flutter_quill_extensions version11.0.0, and unfortunately the pb still occurs...
It should be noted that the problem does not occur on a simple multi-line TextField.

There is also a concrete pb with scrolling down when selectionning.

This video shows comparison between flutter_quill and simple multiline TextField :

flutter_quill_Text.highlighting_selection_issue_compressed.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked This issue cannot be resolved due to an obstacle or dependency. bug Something isn't working critical Requires immediate attention. This issue causes major functionality loss, crashes, or security vulne external issue This issue is caused by an external dependency and cannot be resolved within this project. help wanted Extra attention is needed reproducible This bug has been confirmed and can be reliably reproduced. web Issues or feature requests specific to the Web platform.
Projects
None yet
Development

No branches or pull requests