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

Heading block stops being rendered as a header when deleting the first word #3106

Open
fluiddot opened this issue Feb 4, 2021 · 9 comments
Assignees

Comments

@fluiddot
Copy link
Contributor

fluiddot commented Feb 4, 2021

Describe the bug
While testing the writing flow, specifically the test case "Splitting and merging - TC002 - Merge after selection", I spotted that selecting and deleting the first word, the block stops being rendered as a header, instead it looks like a regular paragraph.

I managed to reproduce it also by selecting and deleting the first letter of the content.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a post/page
  2. Add a Heading block
  3. Write some text
  4. Select the first word (it should include the first letter of the content)
  5. Tap Backspace key for deleting it
  6. Observe that the block stops being rendered as a header instead it's rendered as a regular paragraph

NOTE: This issue can only be reproduced using the Samsung Keyboard (factory default). With the Gboard it works as expected.

Expected behavior
Heading block should be always rendered as a header (bigger font size and spacing).

Screenshots

heading-block-issue-android.mp4

Smartphone (please complete the following information):

  • Device: Samsung Galaxy S20 FE 5G
  • OS: Android 10
  • Version: 16.5 and Pre Alpha - Build 94309
@fluiddot fluiddot added [Type] Bug Something isn't working [OS] Android labels Feb 4, 2021
@fluiddot fluiddot mentioned this issue Feb 4, 2021
3 tasks
@lukewalczak
Copy link
Contributor

Hello @fluiddot, after the initial investigation I can say it's related not only with the header but generally with rich text (aztec).

Please notice that first backspace press removes only the selected text style and then second press removes the selected text. The same happens in paragraph when you try to remove first styled word (bold or italic), however it doesn't remove the style layer visually but unselects toolbar buttons responsible for text styles.

From the code perspective JS part is correct, looks like native changes are required. Text comes from nativeEvent within method onSelectionChange initially is correct (wrapped in tags <h2>Example text</h2>), however the same text in that function received after backspace press doesn't have tags (Example).

I've checked the result of getText in method propagateSelectionChanges in file and actually it has the incorrect value (text without html tags), so imo something has to be wrong within methods responsible for handling backspace key in AztecText.

cc: @chipsnyder @hypest

@hypest
Copy link
Contributor

hypest commented Feb 10, 2021

Reminds me of Aztec level issues indeed (see this one and this one for instance) where the issue stems from how Aztec-Android uses Spans to implement the rich-text functionality, deleting markup in the process when hitting backspace(s).

We need to "go back to Aztec" and try to fix the various different writing flow issues that seem to have the same root cause, but until then I think it's fine to keep this ticket open but not actively working on it at the time being.

@tiagomar
Copy link

👋 @fluiddot, I'm not able to reproduce this issue on 22.2-rc-2. Do you mind checking if it's still a thing? 🙇

@fluiddot
Copy link
Contributor Author

👋 @fluiddot, I'm not able to reproduce this issue on 22.2-rc-2. Do you mind checking if it's still a thing? 🙇

Hey @tiagomar, I can still reproduce it in 22.2-rc-2 (see attached video). Note that the Heading block is not transformed but the font size is that part that changes. If you can't reproduce it, maybe it's related to the theme used, could you try with Masu? Thanks 🙇 !

Screen_Recording_20230421_172917_Jetpack.mp4

Tested on Samsung Galaxy S20 FE 5G (Android 13) - Simple site - Theme: Maus

@tiagomar
Copy link

tiagomar commented May 8, 2023

Hey, @fluiddot, that's interesting!
I did try Masu theme and couldn't reproduce it but, after further investigation, now I think I understand why. I don't use the Samsung Keyboard (factory default), but the Gboard instead. I managed to reproduce the issue when I switched to Samsung Keyboard, and I could reproduce with several different themes.

Gboard vs Samsung Keyboard

keyboards.mp4

Tested on Samsung Galaxy Note 20 (Android 12) - Simple site - Theme: Maus

@fluiddot
Copy link
Contributor Author

fluiddot commented May 9, 2023

Hey, @fluiddot, that's interesting!
I did try Masu theme and couldn't reproduce it but, after further investigation, now I think I understand why. I don't use the Samsung Keyboard (factory default), but the Gboard instead. I've managed to reproduce the issue when I switched to Samsung Keyboard, and I could reproduce with several different themes.

Ah, good catch 🙇 . I'll update the issue's description with this information.

@jhnstn
Copy link
Member

jhnstn commented May 9, 2023

FYI I am able to recreate this issue on a Pixel 6 using Hacker's Keyboard

@jhnstn jhnstn self-assigned this May 9, 2023
@derekblank derekblank assigned derekblank and unassigned jhnstn Aug 28, 2023
@derekblank
Copy link
Contributor

I was able to replicate this issue on a Samsung Galaxy S20 FE 5G, and noted some additional observations:

  • In addition to the Masu theme, I was able able to replicate it using the Russell theme, but it is a bit less noticeable.
  • In addition to the Samsung Keyboard, the issue can also be replicated with the Microsoft Swiftkey keyboard. I could not replicate the issue using the Gboard keyboard.
  • The Editor HTML remains correct when the text size changes: <h2 class="wp-block-heading"></h2>, so the issue appears to be purely visual. Also, when toggling between the HTML and Visual modes, the text size returns to the larger "Heading" size.
  • The issue may not be entirely related to the backspace or selection events: the text size also renders the smaller size when the block is initially created and the placeholder text is shown. When typing starts, the text jumps to the larger size. I tried manipulating some of the selection events in ReactAztecBackSpaceEvent.java, but the changes didn't appear to affect behavior. The issue could possibly be related to the logic when accounting for the end of buffer marker: [Gutenberg] Account for the end of buffer marker AztecEditor-Android#928.
Masu theme Russell theme
Heading.Test.mov
Heading.Test.mp4

@fluiddot fluiddot mentioned this issue Sep 6, 2023
4 tasks
@geriux geriux mentioned this issue Nov 29, 2023
4 tasks
@derekblank derekblank removed their assignment Jan 5, 2024
@geriux geriux self-assigned this Mar 11, 2024
@geriux geriux mentioned this issue May 30, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants