@@ -31,9 +31,10 @@ import type { RouterDirection } from '../router/utils/interface';
3131 shadow : true ,
3232} )
3333export class Button implements ComponentInterface , AnchorInterface , ButtonInterface {
34+ private inDatetime = false ;
3435 private inItem = false ;
3536 private inListHeader = false ;
36- private inToolbar = false ;
37+ private inButtons = false ;
3738 private formButtonEl : HTMLButtonElement | null = null ;
3839 private formEl : HTMLFormElement | null = null ;
3940 private inheritedAttributes : Attributes = { } ;
@@ -216,7 +217,12 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
216217 }
217218
218219 componentWillLoad ( ) {
219- this . inToolbar = ! ! this . el . closest ( 'ion-buttons' ) ;
220+ // Check if element is inside a shadow root and get the host if so
221+ const rootNode = this . el . getRootNode ( ) ;
222+ const shadowHost = rootNode instanceof ShadowRoot ? ( rootNode as ShadowRoot ) . host : null ;
223+
224+ this . inDatetime = ! ! this . el . closest ( 'ion-datetime' ) || ( shadowHost ?. tagName === 'ION-DATETIME' ) ;
225+ this . inButtons = ! ! this . el . closest ( 'ion-buttons' ) ;
220226 this . inListHeader = ! ! this . el . closest ( 'ion-list-header' ) ;
221227 this . inItem = ! ! this . el . closest ( 'ion-item' ) || ! ! this . el . closest ( 'ion-item-divider' ) ;
222228 this . inheritedAttributes = inheritAriaAttributes ( this . el ) ;
@@ -233,9 +239,11 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
233239 private get rippleType ( ) {
234240 const hasClearFill = this . fill === undefined || this . fill === 'clear' ;
235241
236- // If the button is in a toolbar, has a clear fill (which is the default)
237- // and only has an icon we use the unbounded "circular" ripple effect
238- if ( hasClearFill && this . hasIconOnly && this . inToolbar ) {
242+ // Use the unbounded "circular" ripple effect if it:
243+ // - Has a clear fill (the default)
244+ // - Only has an icon and
245+ // - Is inside of buttons (used in a toolbar) or a datetime
246+ if ( hasClearFill && this . hasIconOnly && ( this . inButtons || this . inDatetime ) ) {
239247 return 'unbounded' ;
240248 }
241249
@@ -400,7 +408,7 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
400408 } ;
401409 let fill = this . fill ;
402410 if ( fill === undefined ) {
403- fill = this . inToolbar || this . inListHeader ? 'clear' : 'solid' ;
411+ fill = this . inDatetime || this . inButtons || this . inListHeader ? 'clear' : 'solid' ;
404412 }
405413
406414 /**
@@ -426,9 +434,10 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
426434 [ `${ buttonType } -${ shape } ` ] : true ,
427435 [ `${ buttonType } -${ fill } ` ] : true ,
428436 [ `${ buttonType } -strong` ] : strong ,
437+ 'in-datetime' : this . inDatetime ,
429438 'in-toolbar' : hostContext ( 'ion-toolbar' , this . el ) ,
430439 'in-toolbar-color' : hostContext ( 'ion-toolbar[color]' , this . el ) ,
431- 'in-buttons' : hostContext ( 'ion-buttons' , this . el ) ,
440+ 'in-buttons' : this . inButtons ,
432441 'button-has-icon-only' : hasIconOnly ,
433442 'button-has-badge' : hasBadge ,
434443 'button-disabled' : disabled ,
0 commit comments