Skip to content

Commit 7cba076

Browse files
committed
fix(tab-list): keyboard arrows handle for rtl
1 parent 5d4082e commit 7cba076

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

projects/coreui-angular/src/lib/tabs-2/tabs-list/tabs-list.component.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import { FocusKeyManager } from '@angular/cdk/a11y';
22
import {
3+
afterEveryRender,
34
Component,
45
computed,
56
contentChildren,
67
DestroyRef,
78
effect,
9+
ElementRef,
810
inject,
911
input,
1012
InputSignal,
13+
signal,
1114
untracked
1215
} from '@angular/core';
1316
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1417
import { tap } from 'rxjs/operators';
1518
import { TabDirective } from '../tab/tab.directive';
1619
import { TabsService } from '../tabs.service';
20+
import { RtlService } from '../../services';
1721

1822
@Component({
1923
exportAs: 'cTabsList',
@@ -27,7 +31,18 @@ import { TabsService } from '../tabs.service';
2731
})
2832
export class TabsListComponent {
2933
readonly #destroyRef = inject(DestroyRef);
34+
readonly #elementRef = inject(ElementRef);
3035
readonly tabsService = inject(TabsService);
36+
readonly #rtlService = inject(RtlService);
37+
readonly #isRtl = signal(false);
38+
39+
constructor() {
40+
afterEveryRender({
41+
read: () => {
42+
this.#isRtl.set(this.#rtlService.isRTL(this.#elementRef.nativeElement));
43+
}
44+
});
45+
}
3146

3247
/**
3348
* Specify a layout type for component.
@@ -66,9 +81,12 @@ export class TabsListComponent {
6681
if (tabs.length === 0) {
6782
return;
6883
}
84+
85+
const isRtl = this.#isRtl();
86+
6987
this.#focusKeyManager = new FocusKeyManager(tabs)
7088
.skipPredicate((tab) => tab.disabled === true)
71-
.withHorizontalOrientation('ltr')
89+
.withHorizontalOrientation(isRtl ? 'rtl' : 'ltr')
7290
.withHomeAndEnd()
7391
.withWrap();
7492

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy