From 82e5af63d3e009d862b7a62595c386e415b849b3 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 1 Apr 2022 14:34:04 +0200 Subject: [PATCH] fix(cdk/a11y): visually hidden element affecting scrolling We had a `position: absolute` on the visually-hidden element, but it didn't have an actual position which can cause unnecessary scrolling in some cases. Fixes #24597. --- src/cdk/a11y/_index.scss | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cdk/a11y/_index.scss b/src/cdk/a11y/_index.scss index 2db185eb6518..f102614966ea 100644 --- a/src/cdk/a11y/_index.scss +++ b/src/cdk/a11y/_index.scss @@ -21,6 +21,17 @@ // Avoid some cases where the browser will still render the native controls (see #9049). -webkit-appearance: none; -moz-appearance: none; + + // We need at least one of top/bottom/left/right in order to prevent cases where the + // absolute-positioned element is pushed down and can affect scrolling (see #24597). + // `left` was chosen here, because it's the least likely to break overrides where the + // element might have been positioned (e.g. `mat-checkbox`). + left: 0; + + [dir='rtl'] & { + left: auto; + right: 0; + } } }