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

Fix timestamp and read receipt group placement on ThreadView #10335

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f98fcd7
Fix timestamp on bubble layout on threadview
luixxiul Mar 5, 2023
556daae
Fix info event line styles on bubble layout
luixxiul Mar 5, 2023
66ecfac
Fix read receipt group on ThreadView on modern/group layout
luixxiul Mar 5, 2023
c2f0cf6
Align read receipt groups of hidden event lines and normal bubble tiles
luixxiul Mar 5, 2023
6e1688b
Enable the test to check whether read receipt group is visible on bub…
luixxiul Mar 8, 2023
41638c5
Edit padding of hidden event lines
luixxiul Mar 8, 2023
fd669a3
Edit the test to check mx_EventTile_line margin of hidden event on bu…
luixxiul Mar 8, 2023
a26a154
Edit the test to check mx_EventTile inline start margin of hidden eve…
luixxiul Mar 8, 2023
6b5f515
Edit read receipt group on bubble layout
luixxiul Mar 8, 2023
691e00b
Snapshot of the edited EventTile
luixxiul Mar 8, 2023
deb38da
Edit comments and declarations
luixxiul Mar 8, 2023
6cb5e59
Add a comment
luixxiul Mar 8, 2023
30162b4
Remove inset declaration for MessageActionBar on hidden events
luixxiul Mar 8, 2023
a663e7f
lint
luixxiul Mar 8, 2023
41ee51d
Apply the override to selected hidden event line only
luixxiul Mar 9, 2023
9c19038
Add comments
luixxiul Mar 9, 2023
5b7784b
Sort declarations semantically
luixxiul Mar 9, 2023
6c9c48d
Check spacing of selected hidden event
luixxiul Mar 9, 2023
738ffc2
Add a new line
luixxiul Mar 9, 2023
45ca4f4
Merge branch 'develop' into fix-timestamp-readreceipt-threadview-bubb…
luixxiul Mar 9, 2023
f452adb
Edit a comment
luixxiul Mar 9, 2023
dc6b38d
Check if the option buttons of MessageActionBar is visible
luixxiul Mar 9, 2023
dd17368
Merge branch 'develop' into fix-timestamp-readreceipt-threadview-bubb…
luixxiul Mar 9, 2023
6684e0b
Create a variable to display the read receipts group on TimelineCard …
luixxiul Mar 9, 2023
e63aa2b
Remove the obsolete declaration
luixxiul Mar 9, 2023
d1f9eba
Remove redundant declarations
luixxiul Mar 9, 2023
2acac19
Edit a comment
luixxiul Mar 9, 2023
e87f979
Apply spacing style of hidden event line on modern layout to one on b…
luixxiul Mar 9, 2023
7741c61
Merge styles and apply the same style rules of block padding to all o…
luixxiul Mar 9, 2023
bce1619
Removing a nesting
luixxiul Mar 10, 2023
9cd24ff
Remove width declaration here to let inherited value enabled
luixxiul Mar 10, 2023
ac48775
Merge branch 'develop' into fix-timestamp-readreceipt-threadview-bubb…
luixxiul Mar 10, 2023
1e9bb9a
Update res/css/views/right_panel/_TimelineCard.pcss
luixxiul Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 58 additions & 20 deletions cypress/e2e/threads/threads.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,27 @@ describe("Threads", () => {
// Enable the bubble layout
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);

cy.get(".mx_ThreadView .mx_EventTile[data-layout='bubble'].mx_EventTile_last").within(() => {
// TODO: remove this after fixing the issue of ReadReceiptGroup being hidden on the bubble layout
// See: https://github.com/vector-im/element-web/issues/23569
cy.get(".mx_ReadReceiptGroup .mx_BaseAvatar_image").should("exist");

cy.get(".mx_ThreadView").within(() => {
// Make sure the avatar inside ReadReceiptGroup is visible on bubble layout
// TODO: enable this after fixing the issue of ReadReceiptGroup being hidden on the bubble layout
// See: https://github.com/vector-im/element-web/issues/23569
// cy.get(".mx_ReadReceiptGroup .mx_BaseAvatar_image").should("be.visible");
cy.get(
".mx_EventTile[data-layout='bubble'].mx_EventTile_last .mx_ReadReceiptGroup .mx_BaseAvatar_image",
).should("be.visible");

// Make sure the option button of MessageActionBar on the left bubble is visible
cy.get(".mx_EventTile[data-layout='bubble'][data-self='false']")
.should("exist")
.realHover()
.within(() => {
cy.get(".mx_MessageActionBar [aria-label='Options']").should("be.visible");
});

// Make sure the option button of MessageActionBar on the right bubble is visible
cy.get(".mx_EventTile[data-layout='bubble'][data-self='true']")
.should("exist")
.realHover()
.within(() => {
cy.get(".mx_MessageActionBar [aria-label='Options']").should("be.visible");
});
});

// Re-enable the group layout
Expand Down Expand Up @@ -195,20 +207,30 @@ describe("Threads", () => {
percyCSS,
});

cy.get(".mx_ThreadView .mx_GenericEventListSummary[data-layout=group]").within(() => {
cy.get(".mx_EventTile_info.mx_EventTile_last .mx_EventTile_line")
// Select the hidden event
.rightclick();

// Ensure the same CSS style for spacing is applied to the selected hidden event
cy.get(".mx_EventTile_info.mx_EventTile_selected.mx_EventTile_last .mx_EventTile_line").should(
"have.css",
"padding-inline-start",
ThreadViewGroupSpacingStart,
);
});

// Enable bubble layout
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.Bubble);

// Make sure the CSS style for spacing is applied to the hidden event on bubble layout
cy.get(
".mx_ThreadView .mx_GenericEventListSummary[data-layout=bubble] .mx_EventTile_info.mx_EventTile_last",
).within(() => {
cy.get(".mx_EventTile_line .mx_EventTile_content")
// 76px: ThreadViewGroupSpacingStart + 14px + 6px
// 14px: avatar width
// See: _EventTile.pcss
.should("have.css", "margin-inline-start", "76px");
cy.get(".mx_EventTile_line")
// Make sure the margin is NOT applied to mx_EventTile_line
cy.get(".mx_ThreadView .mx_GenericEventListSummary[data-layout=bubble]").within(() => {
cy.get(".mx_EventTile_info.mx_EventTile_last")
// 49px: --EventTile_bubble-margin-inline-start
Copy link
Contributor Author

Choose a reason for hiding this comment

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

.should("have.css", "margin-inline-start", "49px");

cy.get(".mx_EventTile_info.mx_EventTile_last .mx_EventTile_line .mx_EventTile_content")
// Make sure the margin is NOT applied to mx_EventTile_content
Copy link
Contributor Author

Choose a reason for hiding this comment

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

.should("have.css", "margin-inline-start", "0px");
});

Expand Down Expand Up @@ -302,11 +324,27 @@ describe("Threads", () => {
cy.get(".mx_RoomView_body .mx_ThreadSummary .mx_ThreadSummary_sender").should("contain", "Tom");
cy.get(".mx_RoomView_body .mx_ThreadSummary .mx_ThreadSummary_content").should("contain", "Great!");

// User edits & asserts
// User edits
cy.contains(".mx_ThreadView .mx_EventTile_last .mx_EventTile_line", "Great!").within(() => {
cy.get('[aria-label="Edit"]').click({ force: true }); // Cypress has no ability to hover
cy.get(".mx_BasicMessageComposer_input").type(" How about yourself?{enter}");
cy.get(".mx_BasicMessageComposer_input").type(" How about yourself?");
});

// Ensure the read receipt group on the edited message EventTile is visible
cy.get(".mx_ThreadView .mx_EventTile_isEditing .mx_EventTile_receiptSent").should("be.visible");

// Take snapshot of the edited EventTile on modern layout
cy.get(".mx_ThreadView .mx_EventTile_last[data-layout=group]").percySnapshotElement(
"EditMessageComposer on bubble layout",
{
percyCSS,
},
);

// User saves the edit
cy.get(".mx_ThreadView .mx_EventTile_last .mx_EventTile_line .mx_BasicMessageComposer_input").type("{enter}");

// User asserts
cy.get(".mx_RoomView_body .mx_ThreadSummary .mx_ThreadSummary_sender").should("contain", "Tom");
cy.get(".mx_RoomView_body .mx_ThreadSummary .mx_ThreadSummary_content").should(
"contain",
Expand Down
8 changes: 7 additions & 1 deletion res/css/views/right_panel/_BaseCard.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ limitations under the License.

.mx_BaseCard {
--BaseCard_padding-inline: $spacing-8;
--BaseCard_header-button-size: 24px;
--BaseCard_EventTile_line-padding-block: 2px;
--BaseCard_EventTile-spacing-inline: 36px; /* TODO: Use a spacing variable */
--BaseCard_header-button-size: 24px;

/* Moving the read receipts group inside BaseCard */
Copy link
Member

Choose a reason for hiding this comment

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

Comments should be in the imperative ("Move"), not the present participle ("Moving").

But in this case, the useful information is what this variable does, rather than how it is calculated.

Suggested change
/* Moving the read receipts group inside BaseCard */
/* The `inset-inline-end` (ie, `right` offset) for RR groups in bubble mode. */

/* stylelint-disable-next-line declaration-colon-space-after */
--BaseCard_EventTile_bubble_RR-inset-inline-end: calc(
-1 * var(--ReadReceiptGroup_EventBubbleTile-spacing-end) + $container-gap-width + var(--BaseCard_padding-inline)
);

padding: 0 var(--BaseCard_padding-inline);
overflow: hidden;
Expand Down
10 changes: 3 additions & 7 deletions res/css/views/right_panel/_TimelineCard.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,12 @@ limitations under the License.
flex-basis: 48px; /* 12 (padding on message list) + 36 (padding on event lines) */
}

.mx_GenericEventListSummary_unstyledList, /* RR next to a message on the event list summary */
.mx_GenericEventListSummary_unstyledList,
.mx_RoomView_MessageList {
/* RR next to a message on the messsge list */
.mx_EventTile[data-layout="bubble"] {
/* RR next to a message, in either an event list summary or the message list */
.mx_ReadReceiptGroup {
/* 6px: scroll bar width (magic number) */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks that the magic number should in fact have been var(--BaseCard_padding-inline).

/* stylelint-disable-next-line declaration-colon-space-after */
inset-inline-end: calc(
-1 * var(--ReadReceiptGroup_EventBubbleTile-spacing-end) + $container-gap-width + 6px
);
inset-inline-end: var(--BaseCard_EventTile_bubble_RR-inset-inline-end);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

See: https://github.com/matrix-org/matrix-react-sdk/pull/10335/files#diff-5d3e25eb1d22dd7a96e0e87ea9c1298dc7dbce8eb965d30b2d1ebc1436bfec3fR1230

Once more, just linking to a diff isn't very helpful.

In this case, this is a link to the other place that --BaseCard_EventTile_bubble_RR-inset-inline-end is now used.

}

&.mx_EventTile_info {
Expand Down
101 changes: 67 additions & 34 deletions res/css/views/rooms/_EventTile.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -1032,77 +1032,106 @@ $left-gutter: 64px;
--ThreadView_group_spacing-end: 8px; /* same as padding */

.mx_EventTile {
display: flex;
flex-direction: column;
Comment on lines -1035 to -1036
Copy link
Member

Choose a reason for hiding this comment

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

why is it safe to remove these?


.mx_EventTile_roomName {
display: none;
}

/* handling for hidden events (e.g reactions) in the thread view */
&.mx_EventTile_info {
.mx_EventTile_avatar {
position: absolute;
top: 1.5px; /* Align with hidden event content */
margin-top: 0;
margin-bottom: 0;
margin-block: 0;
Comment on lines -1047 to +1042
Copy link
Member

Choose a reason for hiding this comment

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

I have to say, I find the separate margin-top and margin-bottom properties easier to reason about. Is there a particular reason to prefer margin-block?

width: 14px; /* avatar img size */
height: 14px; /* avatar img size */
}

.mx_ViewSourceEvent_toggle {
display: none; /* hide the hidden event expand button, not enough
space, view source can still be used */
}

Comment on lines -1053 to -1057
Copy link
Member

Choose a reason for hiding this comment

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

is moving this necessary?

&.mx_EventTile_selected .mx_EventTile_line,
.mx_EventTile_line {
$line-height: $font-12px;

padding-inline-start: 0;
line-height: $line-height;

/* hidden event content */
.mx_EventTile_content,
/* redacted hidden event */
.mx_RedactedBody {
width: auto;
font-size: $line-height;
}
}

.mx_ViewSourceEvent_toggle {
display: none; /* hide the hidden event expand button, not enough
space, view source can still be used */
}

/* Required for override */
&[data-layout="irc"],
&[data-layout="group"],
&[data-layout="bubble"] {
/* Override
.mx_ThreadView .mx_EventTile[data-layout="group"],
.mx_GenericEventListSummary[data-layout="bubble"][data-expanded="true"] .mx_EventTile_info */
padding-block: 0;

/* Add padding to hidden event line of all of the layouts, including bubble layout */
.mx_EventTile_line {
padding-block: var(--BaseCard_EventTile_line-padding-block);
}
}

&[data-layout="irc"],
&[data-layout="group"] {
padding-top: 0;

.mx_EventTile_avatar {
position: absolute;
top: 1.5px; /* Align with hidden event content */
left: calc($MessageTimestamp_width + 14px - 4px); /* 14px: avatar width, 4px: align with text */
z-index: 9; /* position above the hover styling */
}

.mx_MessageTimestamp {
top: 2px; /* Align with avatar */
}

&.mx_EventTile_selected .mx_EventTile_line,
.mx_EventTile_line {
.mx_EventTile_content,
.mx_RedactedBody {
/* Add space between avatar and hidden event content */
/* 14px: avatar width, 6px: 20px - 14px */
margin-inline-start: calc(14px + 6px);
}
}

&.mx_EventTile_selected .mx_EventTile_line {
/* Override
.mx_EventTile[data-layout="group"].mx_EventTile_info.mx_EventTile_selected .mx_EventTile_line */
padding-inline-start: var(--ThreadView_group_spacing-start);
}

.mx_MessageTimestamp {
top: 2px; /* Align with avatar */
}

.mx_ReadReceiptGroup {
inset-block-start: calc(-$font-22px); /* Align with hidden event content */
}

&:hover {
&.mx_EventTile_verified.mx_EventTile_info .mx_EventTile_line,
&.mx_EventTile_unverified.mx_EventTile_info .mx_EventTile_line,
&.mx_EventTile_unknown.mx_EventTile_info .mx_EventTile_line {
padding-inline-start: var(--ThreadView_group_spacing-start); /* Override */
}
}
}

&[data-layout="bubble"] {
.mx_EventTile_avatar {
inset-inline-start: 0;
/* Same declaration as the main timeline */
margin-inline: var(--EventTile_bubble-margin-inline-start) 0;

/* Shadow on hover */
&::before {
/* Apply the same value as the main timeline */
inset-inline: calc(-1 * var(--EventTile_bubble-margin-inline-start)) 0;
}

&.mx_EventTile_selected .mx_EventTile_line,
.mx_EventTile_line {
.mx_EventTile_content,
.mx_RedactedBody {
margin-inline-start: calc(var(--ThreadView_group_spacing-start) + 14px + 6px);
}
.mx_ReadReceiptGroup {
/* Move read receipt group inside ThreadView */
inset-inline-end: 0;
}
}
}
Expand Down Expand Up @@ -1172,16 +1201,18 @@ $left-gutter: 64px;
&.mx_EventTile_verified.mx_EventTile_info .mx_EventTile_line,
&.mx_EventTile_unverified.mx_EventTile_info .mx_EventTile_line,
&.mx_EventTile_unknown.mx_EventTile_info .mx_EventTile_line {
padding-inline-start: 0;
padding-inline-start: 0; /* TODO: investigate where this is used */
}
}
}

&[data-layout="bubble"] {
margin-inline: var(--BaseCard_EventTile-spacing-inline);
margin-inline-start: var(--BaseCard_EventTile-spacing-inline);
margin-inline-end: var(--EventTile_bubble-margin-inline-end); /* Reserve space for read receipt group */

&::before {
inset-inline: calc(-1 * var(--BaseCard_EventTile-spacing-inline));
inset-inline-start: calc(-1 * var(--BaseCard_EventTile-spacing-inline));
inset-inline-end: calc(-1 * var(--EventTile_bubble-margin-inline-end));
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.

Copy link
Member

Choose a reason for hiding this comment

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

please don't just link to another line in the diff. What am I supposed to learn by looking at that link?

z-index: auto; /* enable background color on hover */
}

Expand All @@ -1195,9 +1226,11 @@ $left-gutter: 64px;
max-width: var(--EventBubbleTile_line-max-width);
}

&[data-self="true"] {
align-items: flex-end;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

again, what do I learn by looking at that link?

.mx_ReadReceiptGroup {
inset-inline-end: var(--BaseCard_EventTile_bubble_RR-inset-inline-end);
}

&[data-self="true"] {
.mx_EventTile_line.mx_EventTile_mediaLine {
margin: 0 var(--EventTile_bubble_line-margin-inline-end) 0 0; /* align with normal messages */
}
Expand Down
5 changes: 4 additions & 1 deletion res/css/views/rooms/_ReadReceiptGroup.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_ReadReceiptGroup {
/* Required due to alphabetic order of CSS import */
Copy link
Member

Choose a reason for hiding this comment

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

we do this elsewhere without a comment; I don't think the comment here is that helpful.

Suggested change
/* Required due to alphabetic order of CSS import */

:root {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise this variable could not be used on res/css/views/right_panel/_BaseCard.pcss (and any CSS files imported before this file).

--ReadReceiptGroup_EventBubbleTile-spacing-end: 78px;
Copy link
Member

Choose a reason for hiding this comment

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

it would be good to add a comment saying what this variable does though. I'm struggling to figure it out. The best definition I came up with was:

Suggested change
--ReadReceiptGroup_EventBubbleTile-spacing-end: 78px;
/* The negative of the `inset-inline-end` of ReadReceiptGroups in bubble mode. */
--ReadReceiptGroup_EventBubbleTile-spacing-end: 78px;

Any better ideas?

(why isn't it just -78px, to save us doing calc(-1 * var(--ReadReceiptGroup_EventBubbleTile-spacing-end)) everywhere it is used?)

}

.mx_ReadReceiptGroup {
position: relative;
display: inline-block;
user-select: none;
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1197,8 +1197,8 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
<a href={permalink} onClick={this.onPermalinkClicked}>
{timestamp}
</a>
{msgOption}
</div>,
msgOption,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I didn't understand what these links were supposed to tell me. For the benefit of future reviewers:

This brings TimelineRenderingType.Thread in line with the other timeline rendering types by moving the msgOption (ie, the read receipt group) outside the mx_EventTile_line.

reactionsRow,
],
);
Expand Down