Sitecore / jss

Software development kit for JavaScript developers building web applications with Sitecore Experience Platform
https://jss.sitecore.com
Apache License 2.0
261 stars 275 forks source link

Class overwrite when using internal links with *scGenericLink and *scRouterLink #543

Closed jcoronel94 closed 2 years ago

jcoronel94 commented 3 years ago

Description

Hi, Similar to #378 , classes are being overwritten when using the scGenericLink and scRouterLink directives with internal links. According the angular sample app, these directives are alternatives to the *scLink directive.

Expected behavior

Classes should preserve and if a class is set on internalLink field then it should append.

Steps To Reproduce

  1. Start application in connected mode
  2. Try to render a internal link with class set on the html and with no class set on the internalLink Field. <a class="foo" *scGenericLink="rendering.fields.internalLink"></a> <a class="foo" *scRouterLink="rendering.fields.internalLink"></a>

Your Environment

Screenshots

image

image

image

NijasHameed commented 3 years ago

@jcoronel94 Did you find any workaround?, it works with *scLink but nit with alternatives

andreypelykh commented 2 years ago

@NijasHameed There are two workarounds: 1st:

<a *scGenericLink="rendering.fields.internalLink; attrs: {class: 'foo'}"></a>

2nd:

<a [class]="'foo'" *scGenericLink="rendering.fields.internalLink"></a>
illiakovalenko commented 2 years ago

Fixed in #1050