@@ -8,7 +8,7 @@ import '../../focus/md-focus-ring.js';
88import '../../ripple/ripple.js' ;
99
1010import { html , isServer , LitElement , nothing } from 'lit' ;
11- import { property , query , queryAssignedElements } from 'lit/decorators.js' ;
11+ import { property , queryAssignedElements } from 'lit/decorators.js' ;
1212
1313import { ARIAMixinStrict } from '../../internal/aria/aria.js' ;
1414import { mixinDelegatesAria } from '../../internal/aria/delegate.js' ;
@@ -17,10 +17,6 @@ import {
1717 setupFormSubmitter ,
1818 type FormSubmitterType ,
1919} from '../../internal/controller/form-submitter.js' ;
20- import {
21- dispatchActivationClick ,
22- isActivationClick ,
23- } from '../../internal/events/form-label-activation.js' ;
2420import {
2521 internals ,
2622 mixinElementInternals ,
@@ -121,24 +117,23 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter {
121117 return this [ internals ] . form ;
122118 }
123119
124- @query ( '.button' ) private readonly buttonElement ! : HTMLElement | null ;
125-
126120 @queryAssignedElements ( { slot : 'icon' , flatten : true } )
127121 private readonly assignedIcons ! : HTMLElement [ ] ;
128122
129123 constructor ( ) {
130124 super ( ) ;
131- if ( ! isServer ) {
132- this . addEventListener ( 'click' , this . handleClick . bind ( this ) ) ;
133- }
134- }
135-
136- override focus ( ) {
137- this . buttonElement ?. focus ( ) ;
138- }
139-
140- override blur ( ) {
141- this . buttonElement ?. blur ( ) ;
125+ if ( isServer ) return ;
126+ this . addEventListener ( 'click' , ( event ) => {
127+ // If the button is soft-disabled or a disabled link, we need to
128+ // explicitly prevent the click from propagating to other event listeners
129+ // as well as prevent the default action. This is because the underlying
130+ // `<button>` or `<a>` element is not actually `:disabled`.
131+ if ( this . softDisabled || ( this . disabled && this . href ) ) {
132+ event . stopImmediatePropagation ( ) ;
133+ event . preventDefault ( ) ;
134+ return ;
135+ }
136+ } ) ;
142137 }
143138
144139 protected override render ( ) {
@@ -211,23 +206,6 @@ export abstract class Button extends buttonBaseClass implements FormSubmitter {
211206 ` ;
212207 }
213208
214- private handleClick ( event : MouseEvent ) {
215- // If the button is soft-disabled or a disabled link, we need to explicitly
216- // prevent the click from propagating to other event listeners as well as
217- // prevent the default action.
218- if ( this . softDisabled || ( this . disabled && this . href ) ) {
219- event . stopImmediatePropagation ( ) ;
220- event . preventDefault ( ) ;
221- return ;
222- }
223-
224- if ( ! isActivationClick ( event ) || ! this . buttonElement ) {
225- return ;
226- }
227- this . focus ( ) ;
228- dispatchActivationClick ( this . buttonElement ) ;
229- }
230-
231209 private handleSlotChange ( ) {
232210 this . hasIcon = this . assignedIcons . length > 0 ;
233211 }
0 commit comments