MAINT: Use hidden spans rather than copy event listeners for handling chat room header copies

The previous listener could not handle partial selections
This commit is contained in:
bananarama92 2025-04-10 19:12:53 +02:00
parent 754076b594
commit eaa2807009
No known key found for this signature in database
GPG key ID: E83C7D3B5DA36248
2 changed files with 6 additions and 21 deletions
BondageClub
CSS
Screens/Online/ChatRoom

View file

@ -47,6 +47,10 @@
margin-block: 0.1em;
}
.chat-room-sep-image > span {
opacity: 0;
}
.chat-room-no-copy {
user-select: none;
}

View file

@ -913,25 +913,6 @@ var ChatRoomSep = {
*/
ActiveElem: null,
/**
* @private
* @type {(this: HTMLDivElement, event: ClipboardEvent) => void}
*/
_CopyHeader: function _CopyHeader(ev) {
let txt = "";
for (const el of this.childNodes) {
if (!(el instanceof Element)) {
txt += el.textContent;
continue;
} else if (el.classList.contains("chat-room-no-copy")) {
continue;
}
txt += el.textContent || (el.getAttribute("aria-label") ?? "");
}
ev.clipboardData.setData("text/plain", txt);
ev.preventDefault();
},
/**
* Click event listener for collapsing one or more chat room separators
* @private
@ -979,7 +960,7 @@ var ChatRoomSep = {
attributes: { role: "img", "aria-label": InterfaceTextGet(`ChatRoomSpace${button.dataset.space || "F"}`) },
classList: ["chat-room-sep-image"],
style: { mask: `url(${namespace.src}) center/contain` },
eventListeners: { copy: ChatRoomSep._CopyImage },
children: [{ tag: "span", children: [InterfaceTextGet(`ChatRoomSpace${button.dataset.space || "F"}`)] }],
}),
" - ",
] : undefined,
@ -989,7 +970,7 @@ var ChatRoomSep = {
attributes: { role: "img", "aria-label": InterfaceTextGet("Private") },
classList: ["chat-room-sep-image"],
style: { mask: `url(${FriendListIconMapping.Private.src}) center/contain` },
eventListeners: { copy: ChatRoomSep._CopyImage },
children: [{ tag: "span", children: [InterfaceTextGet("Private")] }],
}),
" - ",
] : undefined,