FIX: Unassign buttons on the activity/assigned page don't work (#559)

We've noticed that when unassigning a topic on the `activity/assigned` one of 
two incorrect things happens when pressing this button:
1. The first topic on the page gets unassigned instead of the selected one
2. No topics get unassigned (that happens when the first topic on the list is 
not assigned and only has assigned _posts_)

That happens because this handler for all buttons somehow always use the 
same state - the state of the first topic on the page:

f2906e0885/assets/javascripts/discourse/components/assign-actions-dropdown.js (L55-L68)

There seem to be some nuances in select-kit and I'm not sure whether 
this should be qualified as a bug in select-kit. However, I've noticed that in other cases when we use `DropdownSelectBoxComponent` we use the `onChange` handler rather 
than `onSelect`.

So I switched this code to using `onChange` and that resolved the issue, 
the `onChange` handler has access to correct state.

Tests will be in a follow-up.
This commit is contained in:
Andrei Prigorshnev 2024-04-04 20:03:03 +04:00 committed by GitHub
parent f2906e0885
commit 0bcd0a1fee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -52,7 +52,7 @@ export default DropdownSelectBoxComponent.extend({
}, },
@action @action
onSelect(id) { onChange(id) {
switch (id) { switch (id) {
case "unassign": case "unassign":
this.unassign(this.topic.id); this.unassign(this.topic.id);