Skip to content

Commit a112dfe

Browse files
authored
Fix: Allow triple-click text selection to flow around pills (#30349)
* Fix: Allow triple-click text selection to flow around keyword pills * Fix: Remove unnecessary align-items property from Pill component * Change display property of .mx_Pill from inline to inline-block to fix rendering issue in Playwright tests * Add test for triple-click message selection with pills
1 parent 4b4cb89 commit a112dfe

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

playwright/e2e/permalinks/permalinks.spec.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,51 @@ test.describe("permalinks", () => {
100100
});
101101
});
102102
});
103+
104+
test.describe("triple-click message selection", () => {
105+
test.use({
106+
displayName: "Alice",
107+
});
108+
109+
test("should select entire message line when triple-clicking on message with pills", async ({
110+
page,
111+
app,
112+
user,
113+
bot,
114+
}) => {
115+
await bot.prepareClient();
116+
117+
const roomId = await app.client.createRoom({ name: "Test Room" });
118+
await app.client.inviteUser(roomId, bot.credentials.userId);
119+
await app.viewRoomByName("Test Room");
120+
121+
// Send a message with user and room pills
122+
await app.client.sendMessage(
123+
roomId,
124+
`Testing triple-click message selection. ` +
125+
`User: ${permalinkPrefix}${bot.credentials.userId}, ` +
126+
`Room: ${permalinkPrefix}${roomId}, ` +
127+
`Message: ${permalinkPrefix}${roomId}/$dummy-event, ` +
128+
`and @room mention.`,
129+
);
130+
131+
const timeline = page.locator(".mx_RoomView_timeline");
132+
const messageTile = timeline.locator(".mx_EventTile").last();
133+
134+
// Triple-click on the message body to select its entire content
135+
const messageBody = messageTile.locator(".mx_EventTile_body");
136+
await messageBody.click({ clickCount: 3 });
137+
138+
// Get the expected text content of the message, including pills
139+
const expectedText = await messageBody.innerText();
140+
141+
// Get the currently selected text from the page
142+
const selectedText = await page.evaluate(() => {
143+
const selection = window.getSelection();
144+
return selection ? selection.toString().trim() : "";
145+
});
146+
147+
// Verify that the selected text exactly matches the message content
148+
expect(selectedText).toBe(expectedText);
149+
});
150+
});

res/css/views/elements/_Pill.pcss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Please see LICENSE files in the repository root for full details.
1111
line-height: $font-17px;
1212
border-radius: $font-16px;
1313
vertical-align: text-top;
14-
display: inline-flex;
15-
align-items: center;
14+
display: inline-block;
1615
box-sizing: border-box;
1716
max-width: 100%;
1817
overflow: hidden;
@@ -57,6 +56,8 @@ Please see LICENSE files in the repository root for full details.
5756
margin-inline-start: -0.3em; /* Otherwise the gap is too large */
5857
margin-inline-end: 0.2em;
5958
min-width: $font-16px; /* ensure the avatar is not compressed */
59+
user-select: text;
60+
vertical-align: -2.5px;
6061
}
6162

6263
.mx_Pill_text {

0 commit comments

Comments
 (0)