Skip to content

Commit ae2423f

Browse files
Bug/EUI 3041 tab name (#640)
* retain the tab name instead of index value * package.json and release notes 2.67.2-tab-name Co-authored-by: Uday Denduluri <[email protected]>
1 parent d01e04d commit ae2423f

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

RELEASE-NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## RELEASE NOTES
22

3+
### Version 2.67.2-tab-name
4+
**EUI-3041** Use Tab name instead of Index
5+
36
### Version 2.67.1-focus-order
47
**EUI-2020** Accessibility amends for tabs and page load
58

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hmcts/ccd-case-ui-toolkit",
3-
"version": "2.67.1-focus-order",
3+
"version": "2.67.2-tab-name",
44
"engines": {
55
"yarn": "^1.12.3",
66
"npm": "^5.6.0"

src/shared/components/case-viewer/case-viewer.component.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class CaseViewerComponent implements OnInit, OnDestroy, AfterViewInit {
3131
public static readonly ORIGIN_QUERY_PARAM = 'origin';
3232
static readonly TRIGGER_TEXT_START = 'Go';
3333
static readonly TRIGGER_TEXT_CONTINUE = 'Ignore Warning and Go';
34+
static readonly space = '%20';
3435

3536
@Input()
3637
hasPrint = true;
@@ -53,7 +54,7 @@ export class CaseViewerComponent implements OnInit, OnDestroy, AfterViewInit {
5354
dialogConfig: MatDialogConfig;
5455

5556
callbackErrorsSubject: Subject<any> = new Subject();
56-
@ViewChild('tabGroup') public tabGroup: any;
57+
@ViewChild('tabGroup') public tabGroup: MatTabGroup;
5758

5859
constructor(
5960
private ngZone: NgZone,
@@ -206,9 +207,11 @@ export class CaseViewerComponent implements OnInit, OnDestroy, AfterViewInit {
206207

207208
public ngAfterViewInit() {
208209
const url = this.location.path(true);
209-
const hashValue = url.substring(url.indexOf('#') + 1);
210-
if(hashValue && !isNaN(Number(hashValue))) {
211-
this.tabGroup.selectedIndex = Number(hashValue);
210+
let hashValue = url.substring(url.indexOf('#') + 1);
211+
hashValue = hashValue.replace(CaseViewerComponent.space, ' ');
212+
const matTab = this.tabGroup._tabs.find((x) => x.textLabel === hashValue);
213+
if(matTab && matTab.position) {
214+
this.tabGroup.selectedIndex = matTab.position;
212215
}
213216
}
214217

@@ -248,7 +251,7 @@ export class CaseViewerComponent implements OnInit, OnDestroy, AfterViewInit {
248251
}
249252

250253
public tabChanged(tabChangeEvent: MatTabChangeEvent): void {
251-
window.location.hash = tabChangeEvent.index.toString();
254+
window.location.hash = tabChangeEvent.tab.textLabel;
252255
}
253256

254257
}

0 commit comments

Comments
 (0)