@@ -46,11 +46,17 @@ export class PostReactionComponent {
46
46
}
47
47
48
48
private setupSubmitHandler ( ) {
49
+ const buttons = this . reactionListContainer . querySelectorAll ( 'button' ) ;
50
+
51
+ function toggleButtons ( disabled : boolean ) {
52
+ buttons . forEach ( b => b . disabled = disabled ) ;
53
+ }
54
+
49
55
const handler = async ( event : Event ) => {
50
56
event . preventDefault ( ) ;
51
57
52
58
const button = event . target as HTMLButtonElement ;
53
- button . disabled = true ;
59
+ toggleButtons ( true ) ;
54
60
const id = button . value as ReactionID ;
55
61
const issueExists = ! ! this . issue ;
56
62
@@ -74,19 +80,17 @@ export class PostReactionComponent {
74
80
this . reactions [ id ] += delta ;
75
81
this . reactions . total_count += delta ;
76
82
this . issue ! . reactions = this . reactions ;
77
- button . disabled = false ;
83
+ toggleButtons ( false ) ;
78
84
this . setIssue ( this . issue ) ;
79
85
}
80
86
81
- const buttons = this . element . querySelectorAll ( 'button[post-reaction]' ) ;
82
- buttons . forEach ( button => button . addEventListener ( 'click' , handler , true ) )
87
+ buttons . forEach ( b => b . addEventListener ( 'click' , handler , true ) )
83
88
}
84
89
85
90
private getSubmitButtons ( ) : string {
86
91
function buttonFor ( url : string , reaction : ReactionID , disabled : boolean , count : number ) : string {
87
92
return `
88
93
<button
89
- post-reaction
90
94
type="submit"
91
95
action="javascript:"
92
96
formaction="${ url } "
0 commit comments