Skip to content

Commit

Permalink
Fix background reset on new next version (#111)
Browse files Browse the repository at this point in the history
* Fix background reset

* Remove console logs
  • Loading branch information
emilkowalski authored Sep 22, 2023
1 parent 0270960 commit 89219b6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 80 deletions.
145 changes: 74 additions & 71 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function set(el?: Element | HTMLElement | null, styles?: Style, ignoreCac
});

if (ignoreCache) return;

cache.set(el, originalStyles);
}

Expand Down
16 changes: 8 additions & 8 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ function Root({
resetDrawer();
}

React.useEffect(() => {
// Trigger enter animation without using CSS animation
if (isOpen) {
setVisible(true);
scaleBackground(true);
}
}, [isOpen]);

function scaleBackground(open: boolean) {
const wrapper = document.querySelector('[vaul-drawer-wrapper]');

Expand Down Expand Up @@ -675,19 +683,11 @@ const Content = React.forwardRef<HTMLDivElement, ContentProps>(function (
keyboardIsOpen,
snapPointsOffset,
visible,
setVisible,
closeDrawer,
scaleBackground,
modal,
} = useDrawerContext();
const composedRef = useComposedRefs(ref, drawerRef);

React.useEffect(() => {
// Trigger enter animation without using CSS animation
setVisible(true);
scaleBackground(true);
}, []);

return (
<DialogPrimitive.Content
onOpenAutoFocus={(e) => {
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"clsx": "^2.0.0",
"eslint": "8.45.0",
"eslint-config-next": "13.4.10",
"next": "13.4.10",
"next": "13.5.1",
"postcss": "8.4.26",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down

0 comments on commit 89219b6

Please sign in to comment.