@@ -28,13 +28,14 @@ export abstract class IgcButtonBaseComponent extends EventEmitterMixin<
2828 delegatesFocus : true ,
2929 } ;
3030
31- private _kbFocus = addKeyboardFocusRing ( this ) ;
31+ protected readonly __internals : ElementInternals ;
32+
33+ private readonly _focusRingManager = addKeyboardFocusRing ( this ) ;
3234
33- protected __internals : ElementInternals ;
3435 protected _disabled = false ;
3536
3637 @query ( '[part="base"]' , true )
37- private _nativeButton ! : HTMLButtonElement ;
38+ private readonly _nativeButton ! : HTMLButtonElement ;
3839
3940 /* alternateName: displayType */
4041 /**
@@ -78,19 +79,19 @@ export abstract class IgcButtonBaseComponent extends EventEmitterMixin<
7879 * @attr [disabled=false]
7980 */
8081 @property ( { type : Boolean , reflect : true } )
81- public get disabled ( ) : boolean {
82- return this . _disabled ;
83- }
84-
8582 public set disabled ( value : boolean ) {
8683 this . _disabled = value ;
8784 this . toggleAttribute ( 'disabled' , Boolean ( this . _disabled ) ) ;
8885 }
8986
87+ public get disabled ( ) : boolean {
88+ return this . _disabled ;
89+ }
90+
9091 /* blazorCSSuppress */
9192 /* alternateType: object */
9293 /** Returns the HTMLFormElement associated with this element. */
93- public get form ( ) {
94+ public get form ( ) : HTMLFormElement | null {
9495 return this . __internals . form ;
9596 }
9697
@@ -101,51 +102,42 @@ export abstract class IgcButtonBaseComponent extends EventEmitterMixin<
101102
102103 /* alternateName: focusComponent */
103104 /** Sets focus in the button. */
104- public override focus ( options ?: FocusOptions ) {
105+ public override focus ( options ?: FocusOptions ) : void {
105106 this . _nativeButton . focus ( options ) ;
106107 }
107108
108109 /** Simulates a mouse click on the element */
109- public override click ( ) {
110+ public override click ( ) : void {
110111 this . _nativeButton . click ( ) ;
111112 }
112113
113114 /* alternateName: blurComponent */
114115 /** Removes focus from the button. */
115- public override blur ( ) {
116+ public override blur ( ) : void {
116117 this . _nativeButton . blur ( ) ;
117118 }
118119
119- protected handleBlur ( ) {
120- this . _kbFocus . reset ( ) ;
121- }
122-
123- protected handleClick ( ) {
124- this . _kbFocus . reset ( ) ;
125- switch ( this . type ) {
126- case 'submit' :
127- return this . form ?. requestSubmit ( ) ;
128- case 'reset' :
129- return this . form ?. reset ( ) ;
130- default :
131- return ;
120+ protected _handleClick ( ) : void {
121+ if ( this . type === 'submit' ) {
122+ this . form ?. requestSubmit ( ) ;
123+ } else if ( this . type === 'reset' ) {
124+ this . form ?. reset ( ) ;
132125 }
133126 }
134127
135- protected formDisabledCallback ( state : boolean ) {
128+ protected formDisabledCallback ( state : boolean ) : void {
136129 this . _disabled = state ;
137130 this . requestUpdate ( ) ;
138131 }
139132
140133 private renderButton ( ) {
141134 return html `
142135 < button
143- part =${ partMap ( { base : true , focused : this . _kbFocus . focused } ) }
136+ part =${ partMap ( { base : true , focused : this . _focusRingManager . focused } ) }
144137 aria-label =${ ifDefined ( this . ariaLabel ?? nothing ) }
145138 ?disabled=${ this . disabled }
146139 type=${ ifDefined ( this . type ) }
147- @click=${ this . handleClick }
148- @blur=${ this . handleBlur }
140+ @click=${ this . _handleClick }
149141 >
150142 ${ this . renderContent ( ) }
151143 </ button >
@@ -155,15 +147,14 @@ export abstract class IgcButtonBaseComponent extends EventEmitterMixin<
155147 private renderLinkButton ( ) {
156148 return html `
157149 < a
158- part =${ partMap ( { base : true , focused : this . _kbFocus . focused } ) }
150+ part =${ partMap ( { base : true , focused : this . _focusRingManager . focused } ) }
159151 role ="button"
160152 aria-label=${ ifDefined ( this . ariaLabel ?? nothing ) }
161153 aria-disabled=${ this . disabled }
162154 href=${ ifDefined ( this . href ) }
163155 target=${ ifDefined ( this . target ) }
164156 download=${ ifDefined ( this . download ) }
165157 rel=${ ifDefined ( this . rel ) }
166- @blur=${ this . disabled ? nothing : this . handleBlur }
167158 >
168159 ${ this . renderContent ( ) }
169160 </ a >
0 commit comments