File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -298,26 +298,29 @@ class Autocomplete extends Controller {
298
298
}
299
299
300
300
class Button extends Controller {
301
+ static values = {
302
+ disabled : Boolean
303
+ } ;
301
304
disable ( event ) {
302
- if ( this . button . disabled ) {
305
+ if ( this . disabledValue ) {
303
306
if ( event ) event . preventDefault ( ) ;
304
307
} else {
305
- this . button . disabled = true ;
308
+ this . disabledValue = true ;
306
309
this . button . classList . add ( "Polaris-Button--disabled" , "Polaris-Button--loading" ) ;
307
310
this . buttonContent . insertAdjacentHTML ( "afterbegin" , this . spinnerHTML ) ;
308
311
}
309
312
}
310
313
disableWithoutLoader ( event ) {
311
- if ( this . button . disabled ) {
314
+ if ( this . disabledValue ) {
312
315
if ( event ) event . preventDefault ( ) ;
313
316
} else {
314
- this . button . disabled = true ;
317
+ this . disabledValue = true ;
315
318
this . button . classList . add ( "Polaris-Button--disabled" ) ;
316
319
}
317
320
}
318
321
enable ( ) {
319
- if ( this . button . disabled ) {
320
- this . button . disabled = false ;
322
+ if ( this . disabledValue ) {
323
+ this . disabledValue = false ;
321
324
this . button . classList . remove ( "Polaris-Button--disabled" , "Polaris-Button--loading" ) ;
322
325
if ( this . spinner ) this . spinner . remove ( ) ;
323
326
}
Original file line number Diff line number Diff line change 1
1
import { Controller } from "@hotwired/stimulus"
2
2
3
3
export default class extends Controller {
4
+ static values = { disabled : Boolean }
5
+
4
6
disable ( event ) {
5
- if ( this . button . disabled ) {
7
+ if ( this . disabledValue ) {
6
8
if ( event ) event . preventDefault ( )
7
9
} else {
8
- this . button . disabled = true
10
+ this . disabledValue = true
9
11
this . button . classList . add ( "Polaris-Button--disabled" , "Polaris-Button--loading" )
10
12
this . buttonContent . insertAdjacentHTML ( "afterbegin" , this . spinnerHTML )
11
13
}
12
14
}
13
15
14
16
disableWithoutLoader ( event ) {
15
- if ( this . button . disabled ) {
17
+ if ( this . disabledValue ) {
16
18
if ( event ) event . preventDefault ( )
17
19
} else {
18
- this . button . disabled = true
20
+ this . disabledValue = true
19
21
this . button . classList . add ( "Polaris-Button--disabled" )
20
22
}
21
23
}
22
24
23
25
enable ( ) {
24
- if ( this . button . disabled ) {
25
- this . button . disabled = false
26
+ if ( this . disabledValue ) {
27
+ this . disabledValue = false
26
28
this . button . classList . remove ( "Polaris-Button--disabled" , "Polaris-Button--loading" )
27
29
if ( this . spinner ) this . spinner . remove ( )
28
30
}
You can’t perform that action at this time.
0 commit comments