AztecEditor-iOS icon indicating copy to clipboard operation
AztecEditor-iOS copied to clipboard

Fix bullet point's vertical alignment of list items

Open fluiddot opened this issue 4 years ago • 8 comments

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.

  1. Go to a post/page.
  2. Create list with different items.
  3. Add a emoji character to one of the items.

Expected result: Bullet points are properly aligned with the text line.

fluiddot avatar Dec 29 '20 10:12 fluiddot

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.

SergioEstevao avatar Dec 30 '20 00:12 SergioEstevao

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.

guarani avatar Dec 30 '20 01:12 guarani

Ok, I've marked the PR as ready for review 🎊 . Thanks @SergioEstevao and @guarani for reviewing it ❤️ !

fluiddot avatar Dec 30 '20 08:12 fluiddot

@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.

guarani avatar Jan 04 '21 13:01 guarani

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.

Screenshot 2021-01-04 at 15 32 59

Unordered list: Similar to the previous case the text line is displaced.

Screenshot 2021-01-04 at 15 36 25

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:

Screenshot 2021-01-04 at 15 40 50

Text with emojis:

Screenshot 2021-01-04 at 15 38 35

fluiddot avatar Jan 04 '21 14:01 fluiddot

@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.

fluiddot avatar Jan 05 '21 10:01 fluiddot

Hello, is this fix still coming?

kenoButler avatar Oct 08 '23 20:10 kenoButler

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 🙇 !

fluiddot avatar Oct 10 '23 10:10 fluiddot