diplodoc-platform / diplodoc-platform/transform

`.visually-hidden` element breaks scroll

Open
#788 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
69
Forks
59
Avg merge
1d 21h
Merged PRs (30d)
6

Description

### Package version

4.54.0

### Node version

20

### Platform

_No response_

### What steps will reproduce the bug?

When `.yfm` is inside `overflow-y: auto` container without `position: relative`, elements with `.visually-hidden` are rendered on their position, like there is not scroll. Which leads to additional scroll on top level element.

https://github.com/diplodoc-platform/transform/blob/1664bd986aef2b823244ac9f349d0bf71d1ce6be/src/scss/_common.scss#L404

minimal example
```

body {
margin: 0;
height: 100%;
}
.visually-hidden {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
white-space: nowrap;
border: 0;
clip-path: inset(100%);
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.wrapper {
overflow-y: auto;

height: 100%;
background-color: #ccc;
}
.content {
border: 1px solid #000;

background-color: green;
color: black;
}
.placeholder {
height: 3000px;
}




some content

some content
some hidden content



```

### What is the expected behavior?

body in example is not scrollable, only wrapper scrollable

### What do you see instead?

when wrapper scrolled to the end, the body continues to scroll

### Additional information

Consider to add
```
left: -9999px;
top: -9999px;
```
to `.visually-hidden` element.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.