Skip to content

Commit 5d4082e

Browse files
committed
refactor(rtl.service): ensure RTL detection works regardless of HTML attribute or CSS property direction (computed style check)
1 parent 3ea3cc4 commit 5d4082e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

projects/coreui-angular/src/lib/services/rtl.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ export class RtlService {
88

99
isRTL(element?: HTMLElement | null): boolean {
1010
if (element) {
11-
return element.closest('[dir="rtl"]') !== null;
11+
return (
12+
element.closest('[dir="rtl"]') !== null ||
13+
this.#document.defaultView?.getComputedStyle(element).direction === 'rtl'
14+
);
1215
}
1316

14-
return this.#document?.documentElement?.dir === 'rtl' || this.#document?.body?.dir === 'rtl';
17+
return [this.#document?.documentElement?.dir, this.#document?.body?.dir].includes('rtl');
1518
}
1619
}

0 commit comments

Comments
 (0)