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

Add space for vertical stroke on message edit composer on Rich Text Editor mode #10749

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions cypress/e2e/composer/composer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,31 @@ limitations under the License.

import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { SettingLevel } from "../../../src/settings/SettingLevel";
import { Layout } from "../../../src/settings/enums/Layout";

describe("Composer", () => {
let homeserver: HomeserverInstance;

const checkEditComposerIRC = () => {
// Enable IRC layout
cy.setSettingValue("layout", null, SettingLevel.DEVICE, Layout.IRC);

// Assert the IRC layout is enabled
cy.get(".mx_EventTile_isEditing[data-layout=irc]").within(() => {
cy.get(".mx_EditComposer")
// Assert there is space for the vertical stroke on IRC layout
// $selected-message-border-width + var(--EditComposer-padding-inline) = 4 + 3 = 7px
.should("have.css", "padding-inline-start", "7px")
.within(() => {
// Assert that the textbox is rendered
cy.findByRole("textbox").should("exist");
});
});
};

// Hide message timestamp on Percy snapshots
const percyCSS = ".mx_MessageTimestamp { visibility: hidden !important; }";

beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
Expand Down Expand Up @@ -106,6 +127,24 @@ describe("Composer", () => {
});
});
});

describe("EditComposer", () => {
beforeEach(() => {
// Send a message and click "Edit" button to display EditComposer
cy.findByRole("textbox").type("Message{enter}");
cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Edit" }).click();
cy.get(".mx_EventTile_last").findByRole("textbox").should("exist");
});

it("should be rendered properly on IRC layout", () => {
checkEditComposerIRC();

cy.get(".mx_EventTile_isEditing").percySnapshotElement("EditComposer on EventTile - CIDER", {
percyCSS,
widths: [400, 800], // magic numbers to emulate the actual UI
});
});
});
});

describe("Rich text editor", () => {
Expand Down Expand Up @@ -271,5 +310,23 @@ describe("Composer", () => {
cy.get(".mx_EventTile_body a").should("have.attr", "href").and("include", "https://matrix.org/");
});
});

describe("EditComposer", () => {
beforeEach(() => {
// Send a message and click "Edit" button to display EditComposer
cy.findByRole("textbox").type("Message{enter}");
cy.get(".mx_EventTile_last").realHover().findByRole("button", { name: "Edit" }).click();
cy.get(".mx_EventTile_last").findByRole("textbox").should("exist");
});

it("should be rendered properly on IRC layout", () => {
checkEditComposerIRC();

cy.get(".mx_EventTile_isEditing").percySnapshotElement("EditComposer on EventTile - Rich Text Editor", {
percyCSS,
widths: [400, 800], // magic numbers to emulate the actual UI
});
});
});
});
});
1 change: 1 addition & 0 deletions res/css/_common.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ $timeline-image-border-radius: 8px;
--MessageTimestamp-width: $MessageTimestamp_width;
--buttons-dialog-gap-row: $spacing-8;
--buttons-dialog-gap-column: $spacing-8;
--EditComposer-padding-inline: 3px;
}

@media only percy {
Expand Down
4 changes: 1 addition & 3 deletions res/css/views/rooms/_EditMessageComposer.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ limitations under the License.
*/

.mx_EditMessageComposer {
--EditMessageComposer-padding-inline: 3px;

display: flex;
flex-direction: column;
max-width: 100%; /* disable overflow */
width: auto;
gap: 5px;
padding: 3px var(--EditMessageComposer-padding-inline);
padding: 3px var(--EditComposer-padding-inline);

.mx_BasicMessageComposer_input {
border-radius: 4px;
Expand Down
4 changes: 2 additions & 2 deletions res/css/views/rooms/_EventTile.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ $left-gutter: 64px;
}

&.mx_EventTile_isEditing > .mx_EventTile_line {
.mx_EditMessageComposer {
.mx_EditComposer {
/* add space for the stroke on box-shadow */
padding-inline-start: calc($selected-message-border-width + var(--EditMessageComposer-padding-inline));
padding-inline-start: calc($selected-message-border-width + var(--EditComposer-padding-inline));
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/views/rooms/EditMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
if (!room) return null;

return (
<div className={classNames("mx_EditMessageComposer", this.props.className)} onKeyDown={this.onKeyDown}>
<div
className={classNames("mx_EditComposer mx_EditMessageComposer", this.props.className)}
onKeyDown={this.onKeyDown}
>
<BasicMessageComposer
ref={this.editorRef}
model={this.model}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function EditWysiwygComposer({
return (
<ComposerContext.Provider value={defaultContextValue.current}>
<WysiwygComposer
className={classNames("mx_EditWysiwygComposer", className)}
className={classNames("mx_EditComposer mx_EditWysiwygComposer", className)}
initialContent={initialContent}
onChange={onChange}
onSend={editMessage}
Expand Down