A platform for community discussion. Free, open, simple.
UX: remove the post reaction click for initial filter (#40437)
David Battersby41ebb65a9f8d
diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjsindex 2e6b9f173a2..ef2d3f9425d 100644--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-counter.gjs@@ -34,13 +34,6 @@ export default class DiscourseReactionsCounter extends Component {}`;}- get hasOpenMenuForThisPost() {- const menu = this.menu.getByIdentifier(MENU_IDENTIFIER);- return (- !!menu?.expanded && menu.options.data?.post?.id === this.args.post.id- );- }-reactionsChanged(data) {uniqueItemsFromArray(data.reactions).forEach((reaction) => {this.getUsers(reaction);@@ -65,17 +58,6 @@ export default class DiscourseReactionsCounter extends Component {event.stopImmediatePropagation();}- @action- pointerDown(event) {- if (!this.useNewMenu) {- return;- }-- if (this.hasOpenMenuForThisPost) {- event.stopPropagation();- }- }-@actionmouseUp(event) {event.stopImmediatePropagation();@@ -114,17 +96,7 @@ export default class DiscourseReactionsCounter extends Component {event.stopPropagation();event.preventDefault();- const reactionEl = event.target.closest(- ".discourse-reactions-list-emoji[data-reaction-id]"- );- const reactionId = reactionEl?.dataset.reactionId;-- if (this.hasOpenMenuForThisPost) {- this.#switchMenuFilter(reactionId ?? "all");- return;- }-- this.#toggleMenu(event.currentTarget, reactionId);+ this.#toggleMenu(event.currentTarget);return;}@@ -250,15 +222,7 @@ export default class DiscourseReactionsCounter extends Component {);}- #switchMenuFilter(filter) {- document- .querySelector(- `[data-identifier="${MENU_IDENTIFIER}"] [data-reaction-filter="${filter}"]`- )- ?.click();- }-- #toggleMenu(trigger, initialFilter = null) {+ #toggleMenu(trigger) {const virtualElement = {getBoundingClientRect: () => trigger.getBoundingClientRect(),};@@ -271,7 +235,7 @@ export default class DiscourseReactionsCounter extends Component {arrow: true,placement: "bottom",offset: 15,- data: { post: this.args.post, initialFilter },+ data: { post: this.args.post },});}@@ -286,7 +250,6 @@ export default class DiscourseReactionsCounter extends Component {aria-label={{this.counterAriaLabel}}{{on "mousedown" this.mouseDown}}{{on "mouseup" this.mouseUp}}- {{on "pointerdown" this.pointerDown}}{{on "click" this.click}}{{on "keydown" this.keyDown}}>diff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list-emoji.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list-emoji.gjsindex 1cd2b953c6d..f6b9f7fa0bd 100644--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list-emoji.gjs+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-list-emoji.gjs@@ -102,11 +102,7 @@ export default class DiscourseReactionsListEmoji extends Component {<template>{{#if this.useNewMenu}}- <div- class="discourse-reactions-list-emoji"- id={{this.elementId}}- data-reaction-id={{@reaction.id}}- >+ <div class="discourse-reactions-list-emoji" id={{this.elementId}}>{{#if @reaction.count}}{{dEmoji@reaction.iddiff --git a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjsindex e9281bde92d..1736ce0bce2 100644--- a/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs+++ b/plugins/discourse-reactions/assets/javascripts/discourse/components/discourse-reactions-users-menu.gjs@@ -12,7 +12,7 @@ import { i18n } from "discourse-i18n";import CustomReaction from "../models/discourse-reactions-custom-reaction";export default class DiscourseReactionsUsersMenu extends Component {- @tracked activeFilter = this.args.data.initialFilter ?? null;+ @tracked activeFilter = null;fetchUsers = async (page, pageSize) => {const filter = this.activeFilter;diff --git a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rbindex 40c907749b5..2e6cfe2cb02 100644--- a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb+++ b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_list.rb@@ -45,10 +45,6 @@ module PageObjectsdef click_countercontext_component.find(".discourse-reactions-counter").clickend-- def click_counter_number- context_component.find(".discourse-reactions-counter .reactions-counter").click- endendendenddiff --git a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rbindex f1dfb1a62b0..3130f4d30c5 100644--- a/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb+++ b/plugins/discourse-reactions/spec/system/page_objects/post_reactions_popup.rb@@ -17,18 +17,6 @@ module PageObjectsfind("#{SELECTOR} [data-reaction-filter=#{reaction}]").clickend- def has_active_filter?(reaction)- page.has_css?(- "#{SELECTOR} .post-users-popup__filter[data-reaction-filter=#{reaction}].is-active",- )- end-- def has_no_active_filter?(reaction)- page.has_no_css?(- "#{SELECTOR} .post-users-popup__filter[data-reaction-filter=#{reaction}].is-active",- )- end-def has_user?(username)page.has_css?("#{SELECTOR} .post-users-popup__name[data-user-card=#{username}]")enddiff --git a/plugins/discourse-reactions/spec/system/reactions_post_list_spec.rb b/plugins/discourse-reactions/spec/system/reactions_post_list_spec.rbindex 9e77760cfcf..583fd58376e 100644--- a/plugins/discourse-reactions/spec/system/reactions_post_list_spec.rb+++ b/plugins/discourse-reactions/spec/system/reactions_post_list_spec.rb@@ -72,63 +72,12 @@ describe "Reactions | Post reaction user list" doexpect(page).to have_no_css(".post-users-popup__username")end- it "opens the users popup pre-filtered when clicking a specific reaction emoji" do- sign_in(current_user)- visit(post.url)- expect(reactions_list).to have_reaction("heart")-- reactions_list.click_reaction("clap")-- expect(popup).to be_open- expect(popup).to have_active_filter("clap")- expect(popup).to have_no_active_filter("heart")- expect(popup).to have_user(user_3.username)- expect(popup).to have_no_user(user_2.username)- end-- it "opens the users popup with no filter when clicking the counter number" do- sign_in(current_user)- visit(post.url)- expect(reactions_list).to have_reaction("heart")-- reactions_list.click_counter_number-- expect(popup).to be_open- expect(popup).to have_active_filter("all")- end-- it "switches the active filter without reopening the menu when another emoji is clicked" do- sign_in(current_user)- visit(post.url)- expect(reactions_list).to have_reaction("heart")-- reactions_list.click_reaction("heart")- expect(popup).to have_active_filter("heart")-- reactions_list.click_reaction("clap")- expect(popup).to have_active_filter("clap")- expect(popup).to have_no_active_filter("heart")- end-- it "switches to the all filter without reopening the menu when the counter number is clicked" do- sign_in(current_user)- visit(post.url)- expect(reactions_list).to have_reaction("heart")-- reactions_list.click_reaction("heart")- expect(popup).to have_active_filter("heart")-- reactions_list.click_counter_number- expect(popup).to have_active_filter("all")- expect(popup).to have_no_active_filter("heart")- end-it "filters the users popup by reaction" dosign_in(current_user)visit(post.url)expect(reactions_list).to have_reaction("heart")- reactions_list.click_counter_number+ reactions_list.click_counterexpect(popup).to be_openexpect(popup).to have_user(user_2.username)