Skip to content

Commit

Permalink
fix(card-in-card): ensure that the card image is clickable (#8361)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

#8300

### Description

- This PR addresses the issue where the card image within the `<dds-card-in-card>` is not clickable.
- See the issue for more detail - #8300

### Changelog

**New**

- Add a new variable declaration for checking for `<dds-card-in-card-image>` that's wrapped under `<dds-video-cta-container>`.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
proeung authored Feb 26, 2022
1 parent 4e4b155 commit 487e8e9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ class DDSCardInCard extends StableSelectorMixin(DDSCardCTA) {
linkNode.classList.add(`${prefix}--card-in-card`);
}

if (this.querySelector(`${ddsPrefix}-card-in-card-image`)) {
(this.querySelector(`${ddsPrefix}-card-in-card-image`) as HTMLElement).onclick = () =>
const cardInCardImage = this.querySelector(`${ddsPrefix}-card-in-card-image`);
const cardInCardImageVideo = this.parentElement
?.querySelector(`${ddsPrefix}-card-in-card`)
?.shadowRoot?.querySelector('dds-card-in-card-image');

// fires the card cta footer when card image is clicked
if (cardInCardImage || cardInCardImageVideo) {
((cardInCardImage as HTMLElement) || (cardInCardImageVideo as HTMLElement)).onclick = () =>
this.querySelector(`${ddsPrefix}-card-cta-footer`)
?.shadowRoot?.querySelector(`a`)
?.click();
Expand Down

0 comments on commit 487e8e9

Please sign in to comment.