Skip to content

Commit 414d159

Browse files
committed
docs(button): add note on why we need to check both light and shadow dom datetimes
1 parent 0942a8f commit 414d159

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/components/button/button.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
222222
const rootNode = this.el.getRootNode();
223223
const shadowHost = rootNode instanceof ShadowRoot ? (rootNode as ShadowRoot).host : null;
224224

225+
// Check if the button is inside a datetime component.
226+
// This can happen in two ways:
227+
// 1. Light DOM: User passed one or more buttons to the `buttons` slot
228+
// 2. Shadow DOM: Button is rendered by the datetime component itself
225229
this.inDatetime = !!this.el.closest('ion-datetime') || shadowHost?.tagName === 'ION-DATETIME';
226230
this.inButtons = !!this.el.closest('ion-buttons');
227231
this.inListHeader = !!this.el.closest('ion-list-header');

0 commit comments

Comments
 (0)