UX: allow users to click thread title to open it (#24816)

This commit is contained in:
Joffrey JAFFEUX 2023-12-11 13:54:00 +01:00 committed by GitHub
parent 549513e25d
commit 54724f7c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 16 deletions

View File

@ -27,6 +27,10 @@ export default class ChatMessageThreadIndicator extends Component {
return this.args.interactiveUser ?? true;
}
get interactiveThread() {
return this.args.interactiveThread ?? true;
}
@action
setup(element) {
this.element = element;
@ -42,13 +46,15 @@ export default class ChatMessageThreadIndicator extends Component {
this.element.addEventListener("touchCancel", this.cancelTouch);
}
this.element.addEventListener("mousedown", this.openThread, {
passive: true,
});
if (this.interactiveThread) {
this.element.addEventListener("mousedown", this.openThread, {
passive: true,
});
this.element.addEventListener("keydown", this.openThread, {
passive: true,
});
this.element.addEventListener("keydown", this.openThread, {
passive: true,
});
}
}
@action
@ -64,13 +70,15 @@ export default class ChatMessageThreadIndicator extends Component {
this.element.removeEventListener("touchCancel", this.cancelTouch);
}
this.element.removeEventListener("mousedown", this.openThread, {
passive: true,
});
if (this.interactiveThread) {
this.element.removeEventListener("mousedown", this.openThread, {
passive: true,
});
this.element.removeEventListener("keydown", this.openThread, {
passive: true,
});
this.element.removeEventListener("keydown", this.openThread, {
passive: true,
});
}
}
@bind
@ -134,7 +142,7 @@ export default class ChatMessageThreadIndicator extends Component {
{{willDestroy this.teardown}}
role="button"
title={{i18n "chat.threads.open"}}
tabindex="0"
tabindex={{if this.interactiveThread "0" "-1"}}
>
<div class="chat-message-thread-indicator__last-reply-avatar">

View File

@ -1,4 +1,5 @@
import Component from "@glimmer/component";
import { LinkTo } from "@ember/routing";
import { htmlSafe } from "@ember/template";
import replaceEmoji from "discourse/helpers/replace-emoji";
import { escapeExpression } from "discourse/lib/utilities";
@ -16,9 +17,13 @@ export default class ChatThreadTitle extends Component {
<template>
<div class="chat__thread-title-container">
<div class="chat__thread-title">
<span class="chat__thread-title__name">
<LinkTo
class="chat__thread-title__name"
@route="chat.channel.thread"
@models={{@thread.routeModels}}
>
{{this.title}}
</span>
</LinkTo>
<ThreadUnreadIndicator @thread={{@thread}} />
</div>

View File

@ -88,6 +88,7 @@ export default class UserThreads extends Component {
<ThreadIndicator
@message={{thread.originalMessage}}
@interactiveUser={{false}}
@interactiveThread={{false}}
/>
</div>
</div>

View File

@ -1,6 +1,11 @@
.chat__thread-title {
display: flex;
&__name,
&__name:visited {
color: var(--primary);
}
.chat-thread-list-item-unread-indicator {
margin-left: 0.5rem;
}

View File

@ -9,7 +9,9 @@ module PageObjects
end
def open_thread(thread)
find(".chat__user-threads__thread-container[data-id='#{thread.id}']").click
find(
".chat__user-threads__thread-container[data-id='#{thread.id}'] .chat__thread-title__name",
).click
end
end
end