From ccc0e7efb99507692e186ea6d39663d1393a09b1 Mon Sep 17 00:00:00 2001 From: Tudor Morar Date: Mon, 9 Feb 2026 16:36:09 +0200 Subject: [PATCH 1/3] Add host element reference to Button component for data-testid management --- src/components/visual/button/button.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/visual/button/button.tsx b/src/components/visual/button/button.tsx index 2a53c3a0..d971d8d6 100644 --- a/src/components/visual/button/button.tsx +++ b/src/components/visual/button/button.tsx @@ -1,5 +1,5 @@ import type { EventEmitter } from '@stencil/core'; -import { Component, Event, h, Prop } from '@stencil/core'; +import { Component, Element, Event, h, Prop } from '@stencil/core'; import { Button as ButtonComponent } from 'common/Button/Button'; import type { ButtonSizeEnum, ButtonVariantEnum } from '../../../common/Button/button.types'; @@ -10,6 +10,8 @@ import type { ButtonSizeEnum, ButtonVariantEnum } from '../../../common/Button/b shadow: true, }) export class Button { + @Element() hostElement!: HTMLElement; + @Event() buttonClick: EventEmitter; @Prop() class?: string = ''; @@ -18,6 +20,19 @@ export class Button { @Prop() size?: `${ButtonSizeEnum}` = 'large'; @Prop() variant?: `${ButtonVariantEnum}` = 'primary'; + /** + * Stencil reflects `data-testid` to the host element based on the Prop decorator above. + * That causes two DOM nodes with the same `data-testid`: the `` host and + * the inner `