Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix spacing problem of paragraphs around lists #10305

Closed
wants to merge 17 commits into from
Closed

Fix spacing problem of paragraphs around lists #10305

wants to merge 17 commits into from

Conversation

luixxiul
Copy link
Contributor

@luixxiul luixxiul commented Mar 7, 2023

This PR intends to fix a spacing problem of paragraphs (p) around lists (ul and ol) inside .markdown-body.

Fixes element-hq/element-web#24602

Before After
IRC Screenshot from 2023-03-07 21-01-39 Screenshot from 2023-03-07 21-05-28
Modern Screenshot from 2023-03-07 21-03-14 Screenshot from 2023-03-07 21-04-55
Modern (compact): unchanged Screenshot from 2023-03-07 21-03-27 Screenshot from 2023-03-07 21-05-10
Bubble Screenshot from 2023-03-07 21-03-43 Screenshot from 2023-03-07 21-04-13

Signed-off-by: Suguru Hirahara luixxiul@users.noreply.github.com

type: defect

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Here's what your changelog entry will look like:

🐛 Bug Fixes

luixxiul added 12 commits March 7, 2023 20:41
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
@github-actions github-actions bot added Z-Community-PR Issue is solved by a community member's PR T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems labels Mar 7, 2023
.mx_EventTile_content .markdown-body {
p,
ul,
ol,
Copy link
Contributor Author

@luixxiul luixxiul Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if the margin-bottom for ul and ol on compact modern layout has been expected, as the other layouts do not have margin-bottom for them.

// Check block margin values of paragraphs and lists on compact modern layout
cy.setSettingValue("useCompactLayout", null, SettingLevel.DEVICE, true);
cy.get(".mx_EventTile[data-layout=group] .markdown-body").within(() => {
cy.get("ul").should("have.css", "margin-block", "0px 4px");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ul and ol margin is in fact not expected here, this needs to be replaced as well. https://github.com/matrix-org/matrix-react-sdk/pull/10305/files#r1127766737

@luixxiul luixxiul marked this pull request as ready for review March 7, 2023 12:56
@luixxiul luixxiul requested a review from a team as a code owner March 7, 2023 12:56
@luixxiul luixxiul requested review from richvdh and justjanne March 7, 2023 12:56
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this. A few questions and comments below.

Generally: as I understand it, this works by setting a margin-top for <p> elements which follow a list. What is the reason for doing that, rather than setting a margin-bottom on lists, to bring them into line with the other block elements? I'm worried that with all these overrides, we're making the CSS very hard to reason about, and that there may be other situations that this won't fix.

The problematic margin-bottom override appears to have been introduced in #9871, though I don't entirely follow why it was required. As the author of that PR, @alunturner can you shed any light on it?

res/css/views/rooms/_EventTile.pcss Outdated Show resolved Hide resolved
res/css/views/rooms/_EventTile.pcss Outdated Show resolved Hide resolved
cypress/e2e/timeline/timeline.spec.ts Outdated Show resolved Hide resolved
cypress/e2e/timeline/timeline.spec.ts Outdated Show resolved Hide resolved
Comment on lines 655 to 657
:is(ul, ol) + p {
margin-block: $spacing-16;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be directly overriding the settings at lines 647-650. Do we really need both settings?

Copy link
Contributor Author

@luixxiul luixxiul Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting that ul + p and ol + p would be covered by :is(blockquote > p, ol, ul) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm, I'm mostly asking the same question as in the review summary:

Generally: as I understand it, this works by setting a margin-top for <p> elements which follow a list. What is the reason for doing that, rather than setting a margin-bottom on lists, to bring them into line with the other block elements? I'm worried that with all these overrides, we're making the CSS very hard to reason about, and that there may be other situations that this won't fix.

@@ -648,6 +648,32 @@ $left-gutter: 64px;
margin-top: 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I don't really know why we need a margin-top here. As far as I can tell, it's the default anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me nether.

Comment on lines 672 to 675
/* Paragraph below ul or ol */
:is(ul, ol) + p {
margin-block: $spacing-4;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, how does this interact with the settings at lines 647-650?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
@richvdh richvdh self-requested a review March 8, 2023 14:24
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
@luixxiul
Copy link
Contributor Author

luixxiul commented Mar 8, 2023

Closing for now as setting up a well-thought test set for lists should be done at first.

@luixxiul luixxiul closed this Mar 8, 2023
@artcodespace
Copy link
Contributor

Hello

Thanks for looking at this. A few questions and comments below.

Generally: as I understand it, this works by setting a margin-top for <p> elements which follow a list. What is the reason for doing that, rather than setting a margin-bottom on lists, to bring them into line with the other block elements? I'm worried that with all these overrides, we're making the CSS very hard to reason about, and that there may be other situations that this won't fix.

The problematic margin-bottom override appears to have been introduced in #9871, though I don't entirely follow why it was required. As the author of that PR, @alunturner can you shed any light on it?

Hello!

This work was carried out before I was aware that we were having clashes in the timeline when trying to apply styling purely to the output of the wysiwyg composer. That specific override was put in to handle consecutive list display from the rich text editor, but if it breaks other things, I think it's sensible to be taken out. This is exactly what I did in #10071 to revert an unseen issue with paragraph spacing caused by wysiwyg work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown: There is a strange spacing problem when using the "list".
3 participants