Skip to content

Commit 633e4c2

Browse files
authored
fix(platform): RTL scrolling behavior detection not using cached value in some cases (#18389)
The `getRtlScrollAxisType` function caches its value so that we don't have to hit the DOM multiple times to detect the behavior. The problem is that when it reads the cached value, it does a simple falsy check which will also be true when we've resolved the value to `NORMAL`.
1 parent 8ae7b18 commit 633e4c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cdk/platform/features/scrolling.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const enum RtlScrollAxisType {
2626
}
2727

2828
/** Cached result of the way the browser handles the horizontal scroll axis in RTL mode. */
29-
let rtlScrollAxisType: RtlScrollAxisType;
29+
let rtlScrollAxisType: RtlScrollAxisType|undefined;
3030

3131
/** Check whether the browser supports scroll behaviors. */
3232
export function supportsScrollBehavior(): boolean {
33-
return !!(typeof document == 'object' && 'scrollBehavior' in document.documentElement!.style);
33+
return !!(typeof document == 'object' && 'scrollBehavior' in document.documentElement!.style);
3434
}
3535

3636
/**
@@ -43,7 +43,7 @@ export function getRtlScrollAxisType(): RtlScrollAxisType {
4343
return RtlScrollAxisType.NORMAL;
4444
}
4545

46-
if (!rtlScrollAxisType) {
46+
if (rtlScrollAxisType == null) {
4747
// Create a 1px wide scrolling container and a 2px wide content element.
4848
const scrollContainer = document.createElement('div');
4949
const containerStyle = scrollContainer.style;

0 commit comments

Comments
 (0)