Skip to content

Commit

Permalink
�2.7.3`
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSora committed Apr 22, 2024
1 parent 3eae3ff commit 7fb3bb7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
7 changes: 7 additions & 0 deletions packages/overlayscrollbars/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog

## 2.7.3

### Improvements

- Use `{ preventScroll: true }` when focusing viewport to prevent unwanted scrolling. [#629](https://github.com/KingSora/OverlayScrollbars/issues/629)
- Make the scrollbars hidden when `@media print` applies.

## 2.7.2

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/overlayscrollbars/package.json
@@ -1,7 +1,7 @@
{
"name": "overlayscrollbars",
"private": true,
"version": "2.7.2",
"version": "2.7.3",
"description": "A scrollbar plugin that hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling.",
"author": "Rene Haas | KingSora",
"license": "MIT",
Expand Down
Expand Up @@ -202,7 +202,7 @@ export const createScrollbarsSetupEvents = (
focusedElement === document.body
) {
setT(() => {
_viewport.focus();
_viewport.focus({ preventScroll: true });
}, 25);
}
}),
Expand Down
Expand Up @@ -102,7 +102,7 @@ export const createStructureSetupElements = (
const getDocumentWindow = () => ownerDocument.defaultView || wnd;
const focusElm = (customActiveElm: Element | null) => {
if (customActiveElm && (customActiveElm as HTMLElement).focus) {
(customActiveElm as HTMLElement).focus();
(customActiveElm as HTMLElement).focus({ preventScroll: true });
}
};
const staticInitializationElement = bind(generalStaticInitializationElement, [targetElement]);
Expand Down Expand Up @@ -273,12 +273,11 @@ export const createStructureSetupElements = (
push(destroyFns, bind(removeAttrs, _viewport, dataAttributeViewport));
}

// focus viewport if previously focused element was target, otherwise focus previously focused element
focusElm(
!viewportIsTarget && initActiveElm === targetElement && docWnd.top === docWnd
? _viewport
: initActiveElm
);
// focus viewport if previously focused element was target
if (!viewportIsTarget && initActiveElm === targetElement && docWnd.top === docWnd) {
focusElm(_viewport);
}

undoInitWrapUndwrapFocus();

// @ts-ignore
Expand Down
6 changes: 6 additions & 0 deletions packages/overlayscrollbars/src/styles/scrollbars.scss
Expand Up @@ -96,3 +96,9 @@ body > .os-scrollbar {
top: 0;
bottom: 0;
}

@media print {
.os-scrollbar {
display: none;
}
}

0 comments on commit 7fb3bb7

Please sign in to comment.