AztecEditor-iOS
AztecEditor-iOS copied to clipboard
Fix bullet point's vertical alignment of list items
Fixes https://github.com/wordpress-mobile/AztecEditor-iOS/issues/1314
Description
Align the bullet point vertically with the text line.
How
The marker's (bullet point) render rectangle calculation has been changed.
Origin rectangle
The line fragment rectangle was used as the origin for the calculation, after some checks I realised that unfortunately it's not providing a uniform size (first and last items are providing different heights). For this reason I swapped it to use the used rectangle version (lineFragmentUsedRect) which it provides the same height for all items.
Vertical alignment
The Y offset now is calculated for center it vertically which also required to set the proper height, calculated from the glyph size.
Screenshot
https://user-images.githubusercontent.com/14905380/103278490-e3903680-49cb-11eb-80e9-56bab11bbc92.mp4
How to test
The issue was spotted in the WordPress app which uses a different font family so the issue has to be tested there or modifying the default font for the content in Aztec's example project.
- Go to a post/page.
- Create list with different items.
- Add a emoji character to one of the items.
Expected result: Bullet points are properly aligned with the text line.
Thanks for the PR @fluiddot ! I had a look at the code and it looks correct, I also tested on the Example app and it looks the lists are drawing correctly.
@guarani You may want to test these changes using Gutenberg to see if all is ok.
Thanks for the PR @fluiddot ! I had a look at the code and it looks correct, I also tested on the Example app and it looks the lists are drawing correctly.
@guarani You may want to test these changes using Gutenberg to see if all is ok.
Thanks for taking a look @SergioEstevao! It's good to have an Aztec expert take a look 😄
I'll try this out tomorrow, as I didn't get the chance to look today while I was wrapping up Xposts in Gutenberg.
Ok, I've marked the PR as ready for review 🎊 .
Thanks @SergioEstevao and @guarani for reviewing it ❤️ !
@fluiddot can this be merged and a new release made on https://github.com/wordpress-mobile/AztecEditor-iOS/releases? I think when that's ready, we can include this in the new Gutenberg Mobile release that is going to be cut today.
I've done some tests and I found out that although the bullet point is vertically centered, in some cases it still looks like a bit displaced to the bottom.
This PR improves the way the bullet point is rendered compared to the original bug but unfortunately it doesn't fix it 100%, I think we should review in the future how the bullet point position is calculated.
Examples
Ordered list: In this case the text line is being pushed some pixels down when emojis are added.
Unordered list: Similar to the previous case the text line is displaced.
Text box
As you can see in the following screenshots the bullet point is centered, the problem is that the text box has more space at the top compared to the bottom.
Text without emojis:
Text with emojis:
@fluiddot can this be merged and a new release made on https://github.com/wordpress-mobile/AztecEditor-iOS/releases? I think when that's ready, we can include this in the new Gutenberg Mobile release that is going to be cut today.
After being discussed, since this is a visual glitch it's not so critical to fix it in the new release, we can wait for the next one. This will give me time to rethink the approach and apply some changes in the following days.
Hello, is this fix still coming?
Hello, is this fix still coming?
I changed this PR to draft a long time ago (https://github.com/wordpress-mobile/AztecEditor-iOS/pull/1315#issuecomment-754564160), my idea was to explore other approaches to solve the issues I spotted (https://github.com/wordpress-mobile/AztecEditor-iOS/pull/1315#issuecomment-754021236). However, it's been a while since I stopped working in the PR and I'm not planning to resume it in the short term. I invite other contributors to take over it if there's interest in addressing the issue, thanks 🙇 !