Skip to content
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

Unable to Delete Heading 1 at the Beginning of a Line with Backspace #2180

Closed
1 task done
agata opened this issue Sep 3, 2024 · 9 comments · Fixed by #2198 or #2200
Closed
1 task done

Unable to Delete Heading 1 at the Beginning of a Line with Backspace #2180

agata opened this issue Sep 3, 2024 · 9 comments · Fixed by #2198 or #2200
Labels
bug Something isn't working

Comments

@agata
Copy link
Contributor

agata commented Sep 3, 2024

Is there an existing issue for this?

Flutter Quill version

10.5.5

Steps to reproduce

  1. Apply Heading 1 to the first line.
  2. Enter some text.
  3. Delete the text using the Backspace key.
  4. Continue deleting the space after the text is gone.

Expected results

The Heading 1 style should be removed, and the text should revert to normal formatting.

Actual results

The Heading 1 style is not removed and remains applied. Although the toolbar shows that the text has reverted to normal, the Heading 1 style is still applied, and any new text entered continues to be formatted with Heading 1.

Code sample

Code sample
[Paste your code here]

Additional Context

This issue has been confirmed on macOS, iOS, and Android.

Screenshots / Video demonstration
default.mp4
Logs
[Paste your logs here]
@AtlasAutocode
Copy link
Collaborator

Sorry but we seem to have had a collision over this issue.

I just submitted a PR that simply resolves this problem with minimal changes to raw_editor_actions (line101) consistent with the method used for inline styles.
But I did not realize that you had just submitted a PR using delete rules and raw_editor_state.

Unfortunately, your changes block my changes, so we need to resolve the differences.
As far as I can see, your changes correctly address the backspace removal of style but do not update the toolbar state which still shows header3 active.

If I comment out your call to _handleBackspaceKey the code now removes the heading style and updates the toolbar state. It appears that your handling of the backspace is preventing my updating of the toolbar state.

Can you look into this and see how we can handle the conflict?
Thank you.

@agata
Copy link
Contributor Author

agata commented Sep 10, 2024

@AtlasAutocode

I have confirmed the operation. By commenting out _handleBackspaceKey, your changes work perfectly. It also functions correctly for deleting inline elements, and I particularly like the behavior where text inside a block is not deleted if it remains.

I will submit a pull request to revert this pull request. Thank you.

@AtlasAutocode
Copy link
Collaborator

Thank you for your kind words.
I again apologize - the fault was mine.
I look forward to working with you in the future.

@agata
Copy link
Contributor Author

agata commented Oct 5, 2024

@AtlasAutocode

This improvement only works on the desktop version. On iPhone, even though the toolbar reverts to the normal style when pressing backspace, the header style is not removed. Upon investigation, it seems that the QuillEditorDeleteTextAction is not triggered on mobile devices. Do you have any idea what might be causing this?

@AtlasAutocode
Copy link
Collaborator

Interesting: Running an android emulator, when I use the computer's keyboard, everything works correctly. However, when I use the emulator's keyboard it fails. There must be something peculiar about the keyboard handler.

Another anomaly is: select header1 and enter text. Remove the text using BS on the emulator's keyboard. As soon as the last character is removed, the toolbar loses the header state. This state should be retained and only removed when you press BS one more time. Because this attribute is lost too soon, the code to process the extra BS does not call formatText and QuillEditorDeleteTextAction. This is probably the reason for the failure.

Strangely no other block attribute has this effect. Alignments and lists all work correctly, but font settings (headers, fonts, and line height) all fail. That makes no sense.

I'm tied up with other things at the moment but will try to take another look and dig deeper to see if I can figure out what is happening here.

@agata
Copy link
Contributor Author

agata commented Oct 6, 2024

This issue might be related.

flutter/flutter#142882

@agata
Copy link
Contributor Author

agata commented Oct 6, 2024

The following issue might also be related. It seems that in Flutter, there is no way to handle the delete key event on mobile keyboards.

flutter/flutter#128926

@AtlasAutocode
Copy link
Collaborator

Those posts are very disappointing. How can Flutter be taken seriously when such errors exist?

At present, I am stuck. I had to reinstall Android Studio to fix an unrelated problem. Now, there is an incompatibility between gradle and java because of the latest Android Studio (Ladybug) release which is causing everyone problems!

What this all means is I cannot even build for Android let alone try to figure out what is going on with this issue.

It will probably be faster if you look into this.

The key observations are:

  1. When the last character is removed, the toolbar state changes and is incorrect:
  2. State is incorrectly removed for:
    a. Inline attributes: font (maybe size but didn't check)
    b. Block attributes: Header, line height

Other inline and block attributes work correctly with the backspace on the soft keyboard.

@EchoEllet
Copy link
Collaborator

At present, I am stuck. I had to reinstall Android Studio to fix an unrelated problem. Now, there is an incompatibility between gradle and java because of the latest Android Studio (Ladybug) release which is causing everyone problems!

What this all means is I cannot even build for Android let alone try to figure out what is going on with this issue.

Fixed the issue in #2312 for the example app.

Also, see this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants