From d7108d37c1ca44e1ded59ecaf36f85bbc425e073 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 27 Nov 2024 09:44:19 +0100 Subject: [PATCH] check all of composedPath --- packages/uui-base/lib/mixins/SelectableMixin.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/uui-base/lib/mixins/SelectableMixin.ts b/packages/uui-base/lib/mixins/SelectableMixin.ts index d66d49e48..70871a469 100644 --- a/packages/uui-base/lib/mixins/SelectableMixin.ts +++ b/packages/uui-base/lib/mixins/SelectableMixin.ts @@ -95,9 +95,13 @@ export const SelectableMixin = >( readonly #onClick = (e: Event) => { const composePath = e.composedPath(); - const target = composePath[0] as HTMLElement; + const isAnchorTag = composePath.some(el => { + const element = el as HTMLElement; + return element.tagName === 'A'; + }); - if (target.tagName === 'A') return; + // never select when clicking on a link + if (isAnchorTag) return; const isSelectable = this._selectable || (this.deselectable && this.selected);