Skip to content

Commit a124263

Browse files
authored
refactor: fixing disabled behavior for ht-link (#915)
* refactor: fixing disabled behavior for htlink * revert: revert navigation service changes * refactor: updating condition * refactor: fix lint issue
1 parent 69ce706 commit a124263

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

projects/components/src/link/link.component.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ describe('Link component', () => {
1313
declarations: [MockDirective(RouterLinkWithHref)]
1414
});
1515

16-
test('Link should not be displayed if url is undefined', () => {
16+
test('Link contents should be displayed if params/url is undefined', () => {
1717
spectator = createHost(`<ht-link [paramsOrUrl]="paramsOrUrl"></ht-link>`, {
1818
props: {
1919
paramsOrUrl: undefined
2020
}
2121
});
2222

23-
expect(spectator.query('.ht-link')).not.toExist();
23+
const anchorElement = spectator.query('.ht-link');
24+
expect(anchorElement).toExist();
25+
expect(anchorElement).toHaveClass('ht-link disabled');
2426
});
2527

2628
test('Link should navigate correctly to external URLs', () => {

projects/components/src/link/link.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import { isNil } from 'lodash-es';
99
changeDetection: ChangeDetectionStrategy.OnPush,
1010
template: `
1111
<a
12-
*ngIf="this.navigationPath"
1312
class="ht-link"
14-
[ngClass]="{ disabled: this.disabled }"
13+
[ngClass]="{ disabled: this.disabled || !this.navigationPath }"
1514
[routerLink]="this.navigationPath"
1615
[queryParams]="this.navigationOptions?.queryParams"
1716
[queryParamsHandling]="this.navigationOptions?.queryParamsHandling"

0 commit comments

Comments
 (0)