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

[BUG] list marker alignment broken when setting lineHeight #1016

Closed
quaaantumdev opened this issue Feb 26, 2022 · 3 comments · Fixed by #1161
Closed

[BUG] list marker alignment broken when setting lineHeight #1016

quaaantumdev opened this issue Feb 26, 2022 · 3 comments · Fixed by #1161
Labels
bug Something isn't working lists Issues with <ol>, <ul>, and <li>
Milestone

Comments

@quaaantumdev
Copy link

quaaantumdev commented Feb 26, 2022

Describe the bug:
Setting lineHeight on "li" element breaks alignment of list marker for both "ol" and "ul".

HTML to reproduce the issue:

<ol>
  <li>The dot displayed at the list item</li>
  <li>will be displayed above the middle line</li>
  <li>when setting styles "li" to lineHeight: LineHeight.em(1.3)</li>
</ol>

<ul>
  <li>The number displayed at the list item</li>
  <li>will be displayed above the middle line</li>
  <li>when setting styles "li" to lineHeight: LineHeight.em(1.3)</li>
</ul>

Html widget configuration:

final styles = <String, Style>{
  'body': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
  'ul': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
  'ol': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
  'li': Style(
    lineHeight: LineHeight.em(1.3), // does not matter where you set lineHeight
  ),
}

Expected behavior:
List item markers should be aligned with the text inside the list item.

Screenshots:
image

Device details and Flutter/Dart/flutter_html versions:
flutter_html: 2.2.1 (latest at the moment)
flutter: 2.10.1 (stable)
dart: 2.16.1 (comes with flutter)

Additional info:
Checked the source code, looks like a Row layout with a Text element is created, maybe consider using the textStyle from the list item or allow a custom text style. There is a workarround for "ul" by using "listStyleType: ListStyleType.fromWidget(...)" with some margin on top, but it does not work for "ol" as one cannot provide the numbers dynamically.

A picture of a cute animal (not mandatory but encouraged)
A list of perfectly aligned cats 😺
A list of perfectly aligned cats

@quaaantumdev quaaantumdev added the bug Something isn't working label Feb 26, 2022
@quaaantumdev quaaantumdev changed the title [BUG] [BUG] list alignment broken when setting lineHeight Feb 26, 2022
@quaaantumdev quaaantumdev changed the title [BUG] list alignment broken when setting lineHeight [BUG] list marker alignment broken when setting lineHeight Feb 26, 2022
@untillnesss
Copy link

I have same issue to !!

@untillnesss
Copy link

image

@Sub6Resources Sub6Resources added the lists Issues with <ol>, <ul>, and <li> label Jun 10, 2022
@daniel-tan1
Copy link

I'm facing same problem. Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lists Issues with <ol>, <ul>, and <li>
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants