-
-
Notifications
You must be signed in to change notification settings - Fork 822
Fix spacing problem of paragraphs around lists #10305
Changes from 12 commits
39ca0e3
b96df96
613040f
2525350
d9ebe6e
0578f2c
2e8156a
b34692f
c4d13ef
951a210
09f5cfd
dbe57d6
96be6f7
934e752
7ac5c6c
98adc11
3aef940
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,6 +301,96 @@ describe("Timeline", () => { | |
); | ||
}); | ||
|
||
it("should render lists with paragraphs", () => { | ||
cy.visit("/#/room/" + roomId); | ||
|
||
// Wait until configuration is finished | ||
cy.contains( | ||
".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary", | ||
"created and configured the room.", | ||
).should("exist"); | ||
|
||
// Send unordered & ordered lists with paragraphs | ||
cy.sendEvent(roomId, null, "m.room.message" as EventType, { | ||
msgtype: "m.text" as MsgType, | ||
body: | ||
"Paragraph above lists\n\n" + | ||
"- item 1\n- item 2\n- item 3\n\n" + | ||
"Paragraph between lists\n\n" + | ||
"1. item 1\n2. item 2\n3. item 3\n\n" + | ||
"Paragraph below lists", | ||
format: "org.matrix.custom.html", | ||
formatted_body: | ||
"<p>Paragraph above lists</p>\n" + | ||
"<ul>\n<li>item 1</li>\n<li>item 2</li>\n<li>item 3</li>\n</ul>\n" + | ||
"<p>Paragraph between lists</p>\n" + | ||
"<ol>\n<li>item 1</li>\n<li>item 2</li>\n<li>item 3</li>\n</ol>\n" + | ||
"<p>Paragraph below lists</p>\n", | ||
}); | ||
|
||
// Confirm the paragraph below the lists was rendered | ||
cy.get(".mx_EventTile[data-layout=group] .markdown-body p:last-of-type").should( | ||
"have.text", | ||
"Paragraph below lists", | ||
); | ||
|
||
// This is to check block margin of unordered & ordered lists | ||
const checkMarginList = () => { | ||
cy.get("ul").should("have.css", "margin-block", "0px"); | ||
cy.get("ol").should("have.css", "margin-block", "0px"); | ||
}; | ||
|
||
// This is to check block margin of paragraphs around the lists except on compact modern layout | ||
const checkMarginParagraphsWide = () => { | ||
cy.get("p:first-of-type").should("have.css", "margin-block", "0px 16px"); // Paragraph above lists | ||
cy.get("p:nth-of-type(2)").should("have.css", "margin-block", "16px"); // Paragraph between lists | ||
cy.get("p:last-of-type").should("have.css", "margin-block", "16px 0px"); // Paragraph below lists | ||
}; | ||
luixxiul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Check block margin values of paragraphs and lists on modern layout | ||
cy.get(".mx_EventTile[data-layout=group] .markdown-body").within(() => { | ||
checkMarginList(); | ||
checkMarginParagraphsWide(); | ||
}); | ||
|
||
// Exclude timestamp and read marker from snapshot | ||
const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }"; | ||
cy.get(".mx_MainSplit").percySnapshotElement("Lists with paragraphs on modern layout", { percyCSS }); | ||
|
||
// 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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
cy.get("ol").should("have.css", "margin-block", "0px 4px"); | ||
cy.get("p:first-of-type").should("have.css", "margin-block", "0px 4px"); // Paragraph above lists | ||
cy.get("p:nth-of-type(2)").should("have.css", "margin-block", "4px"); // Paragraph between lists | ||
cy.get("p:last-of-type").should("have.css", "margin-block", "4px 0px"); // Paragraph below lists | ||
}); | ||
cy.setSettingValue("useCompactLayout", null, SettingLevel.DEVICE, false); | ||
|
||
cy.get(".mx_MainSplit").percySnapshotElement("Lists with paragraphs on compact modern layout", { | ||
percyCSS, | ||
}); | ||
|
||
// Check block margin values of paragraphs and lists on IRC layout | ||
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC); | ||
cy.get(".mx_EventTile[data-layout=irc] .markdown-body").within(() => { | ||
checkMarginList(); | ||
checkMarginParagraphsWide(); | ||
}); | ||
|
||
cy.get(".mx_MainSplit").percySnapshotElement("Lists with paragraphs on IRC layout", { percyCSS }); | ||
|
||
// Check block margin values of paragraphs and lists on bubble layout | ||
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble); | ||
cy.get(".mx_EventTile[data-layout=bubble] .markdown-body").within(() => { | ||
checkMarginList(); | ||
checkMarginParagraphsWide(); | ||
}); | ||
|
||
cy.get(".mx_MainSplit").percySnapshotElement("Lists with paragraphs on bubble layout", { percyCSS }); | ||
}); | ||
|
||
it("should set inline start padding to a hidden event line", () => { | ||
sendEvent(roomId); | ||
cy.visit("/#/room/" + roomId); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -648,6 +648,32 @@ $left-gutter: 64px; | |
margin-top: 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I don't really know why we need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me nether. |
||
margin-bottom: 0; | ||
} | ||
|
||
/* EventTile on every layout */ | ||
.mx_EventTile & { | ||
luixxiul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/* Paragraph below ul or ol */ | ||
:is(ul, ol) + p { | ||
margin-block: $spacing-16; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you suggesting that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
} | ||
|
||
/* EventTile on compact modern layout only */ | ||
.mx_MatrixChat_useCompactLayout .mx_EventTile[data-layout="group"] & { | ||
luixxiul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
p, | ||
ul, | ||
ol, | ||
dl, | ||
blockquote, | ||
pre, | ||
table { | ||
margin-bottom: $spacing-4; /* 1/4 of the non-compact margin-bottom */ | ||
} | ||
|
||
/* Paragraph below ul or ol */ | ||
:is(ul, ol) + p { | ||
margin-block: $spacing-4; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, how does this interact with the settings at lines 647-650? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
} | ||
} | ||
} | ||
|
||
|
@@ -1316,18 +1342,6 @@ $left-gutter: 64px; | |
inset-block-start: -2rem; | ||
} | ||
} | ||
|
||
.mx_EventTile_content .markdown-body { | ||
p, | ||
ul, | ||
ol, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if the margin-bottom for |
||
dl, | ||
blockquote, | ||
pre, | ||
table { | ||
margin-bottom: $spacing-4; /* 1/4 of the non-compact margin-bottom */ | ||
} | ||
} | ||
} | ||
|
||
&[data-shape="ThreadsList"][data-notification]::before, | ||
|
Uh oh!
There was an error while loading. Please reload this page.