Skip to content

Commit 2adab35

Browse files
committed
media card selectable solution
1 parent ef1cbae commit 2adab35

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

packages/uui-base/lib/mixins/SelectableMixin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export const SelectableMixin = <T extends Constructor<LitElement>>(
104104

105105
readonly #onKeydown = (e: KeyboardEvent) => {
106106
if (e.code !== 'Space' && e.code !== 'Enter') return;
107-
this.#onClick(e);
107+
if (e.composedPath().indexOf(this.#selectableTarget) === 0) {
108+
this.#onClick(e);
109+
}
108110
};
109111

110112
readonly #onClick = (e: Event) => {

packages/uui-card-media/lib/uui-card-media.element.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export class UUICardMediaElement extends UUICardElement {
9494
ifDefined(
9595
this.target === '_blank' ? 'noopener noreferrer' : undefined,
9696
),
97-
)}>
97+
)}
98+
@click=${(e: MouseEvent) => e.stopPropagation()}>
9899
${this.#renderContent()}
99100
</a>
100101
`;
@@ -120,7 +121,9 @@ export class UUICardMediaElement extends UUICardElement {
120121
<div id="select-border"></div>
121122
122123
<slot name="tag"></slot>
123-
<slot name="actions"></slot>`;
124+
<slot
125+
name="actions"
126+
@click=${(e: MouseEvent) => e.stopPropagation()}></slot>`;
124127
}
125128

126129
static styles = [

packages/uui-card-media/lib/uui-card-media.story.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ export const Actions: Story = {
6464
},
6565
};
6666

67+
export const Href: Story = {
68+
args: {
69+
'actions slot': html`<uui-button
70+
slot="actions"
71+
look="secondary"
72+
label="Remove"
73+
>Remove</uui-button
74+
>`,
75+
selectable: true,
76+
href: 'https://umbraco.com',
77+
target: '_blank',
78+
},
79+
};
80+
6781
export const Image: Story = {
6882
args: {
6983
slot: html`<img src="https://placedog.net/1447/?random" alt="" />`,

0 commit comments

Comments
 (0)