Skip to content

[Bug]: Scroll on modal close #1314

@qruz-hq

Description

@qruz-hq

Current Behavior

Whenever the user closes the connect modal the page is scrolled to the top.

Expected Behavior

The page should stay at the same scroll-y position.

Steps To Reproduce

  1. Install package on a nextJS project
  2. Create a connect button lower the the view-height
  3. Click on the button.

What package is effected by this issue?

@web3-onboard/core

Is this a build or a runtime issue?

Runtime

Package Version

2.9.0-alpha.1

Node Version

16

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Anything else?

The problem seems to be linked to this part of the onDestroy handler :

const scrollY = body.style.top;
body.style.top = '';
window.scrollTo(0, parseInt(scrollY || '0') * -1);
window.removeEventListener('scroll', trackYScrollPosition);

Replacing the scrollYdeclaration with

	const scrollY = html.style.getPropertyValue('--scroll-y');

would most likely fix the issue

For some reason, the body.style.top setter is very inconsistent and works only a few times leaving the scrollY value to 0.

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions