Fix outstanding UX issues with replies/mentions/keyword notifs (#28270)

* Fix outstanding UX issues with replies/mentions/keyword notifs

* Use createRoot instead of deprecated ReactDOM.render

I foresee this change being made across the codebase shortly
and want to proactively prevent my PR from falling behind

* Clean up react root on unmount

* Remove addition of left-edge highlight on message mentions

It is clear that it would be best for me to address
this piece in a separate PR.

* Update call to ReactRootManager.render

---------

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
taffyko
2025-01-22 13:42:40 -08:00
committed by GitHub
parent 9a109cdce8
commit 68c03db557
5 changed files with 108 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/
import React from "react";
import { MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";
import { MatrixClient, MatrixEvent, PushRuleKind } from "matrix-js-sdk/src/matrix";
import { mocked, MockedObject } from "jest-mock";
import { render, waitFor } from "jest-matrix-react";
@@ -228,6 +228,23 @@ describe("<TextualBody />", () => {
const content = container.querySelector(".mx_EventTile_body");
expect(content.innerHTML.replace(defaultEvent.getId(), "%event_id%")).toMatchSnapshot();
});
it("should pillify a keyword responsible for triggering a notification", () => {
const ev = mkRoomTextMessage("foo bar baz");
ev.setPushDetails(undefined, {
actions: [],
pattern: "bar",
rule_id: "bar",
default: false,
enabled: true,
kind: PushRuleKind.ContentSpecific,
});
const { container } = getComponent({ mxEvent: ev });
const content = container.querySelector(".mx_EventTile_body");
expect(content.innerHTML).toMatchInlineSnapshot(
`"<span>foo <bdi><span tabindex="0"><span class="mx_Pill mx_KeywordPill"><span class="mx_Pill_text">bar</span></span></span></bdi> baz</span>"`,
);
});
});
describe("renders formatted m.text correctly", () => {