FIX: toggle topic pinning for user only if thumbtack icon is pressed. (#21917)

Previously, the topic is pinned/unpinned even when the bookmark icon is pressed in the topic list page. Because we didn't check the class names of topic status icons.
This commit is contained in:
Vinoth Kannan 2023-06-07 03:53:39 +05:30 committed by GitHub
parent f682071ed0
commit 899969fd5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,17 +230,19 @@ export default Component.extend({
} }
const topic = this.topic; const topic = this.topic;
if (e.target.classList.contains("bulk-select")) { const target = e.target;
const classList = target.classList;
if (classList.contains("bulk-select")) {
const selected = this.selected; const selected = this.selected;
if (e.target.checked) { if (target.checked) {
selected.addObject(topic); selected.addObject(topic);
if (this.lastChecked && e.shiftKey) { if (this.lastChecked && e.shiftKey) {
const bulkSelects = Array.from( const bulkSelects = Array.from(
document.querySelectorAll("input.bulk-select") document.querySelectorAll("input.bulk-select")
), ),
from = bulkSelects.indexOf(e.target), from = bulkSelects.indexOf(target),
to = bulkSelects.findIndex((el) => el.id === this.lastChecked.id), to = bulkSelects.findIndex((el) => el.id === this.lastChecked.id),
start = Math.min(from, to), start = Math.min(from, to),
end = Math.max(from, to); end = Math.max(from, to);
@ -253,19 +255,19 @@ export default Component.extend({
}); });
} }
this.set("lastChecked", e.target); this.set("lastChecked", target);
} else { } else {
selected.removeObject(topic); selected.removeObject(topic);
this.set("lastChecked", null); this.set("lastChecked", null);
} }
} }
if (e.target.classList.contains("raw-topic-link")) { if (classList.contains("raw-topic-link")) {
if (wantsNewWindow(e)) { if (wantsNewWindow(e)) {
return true; return true;
} }
e.preventDefault(); e.preventDefault();
return this.navigateToTopic(topic, e.target.getAttribute("href")); return this.navigateToTopic(topic, target.getAttribute("href"));
} }
// make full row click target on mobile, due to size constraints // make full row click target on mobile, due to size constraints
@ -282,7 +284,10 @@ export default Component.extend({
return this.navigateToTopic(topic, topic.lastUnreadUrl); return this.navigateToTopic(topic, topic.lastUnreadUrl);
} }
if (e.target.closest("a.topic-status")) { if (
classList.contains("d-icon-thumbtack") &&
target.closest("a.topic-status")
) {
this.topic.togglePinnedForUser(); this.topic.togglePinnedForUser();
return false; return false;
} }