Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] when el-image in a scrolling div. Left clik the image will lead to the page can't scroll #18234

Closed
zzxCNCZ opened this issue Nov 28, 2019 · 10 comments

Comments

@zzxCNCZ
Copy link

zzxCNCZ commented Nov 28, 2019

Element UI version

2.13.0

OS/Browsers version

chrome 78.0.3904.108

Vue version

2.6.10

Reproduction Link

https://codepen.io/zzxcncz/pen/LYYwOXo

Steps to reproduce

click the image ,then the page can't scroll

What is Expected?

click the image ,then the page can scroll

What is actually happening?

click the image ,then the page can scroll.
i fock the code from the element ui website.The demo of the component in the website can also lead the result. Just click the image ,and chage to other page.Then the other page can't scroll.
i found the reason is when i click the image in a scrolling div. it will add a css in .the css is over-flow: hidden.

@zzxCNCZ
Copy link
Author

zzxCNCZ commented Nov 29, 2019

if i don't need preview the image, the click handler will also add a body style overflow = 'hidden'.
this will lead to i can't scroll the page.
the el-image's click handler code.

clickHandler() {
        // prevent body scroll
        prevOverflow = document.body.style.overflow;
        document.body.style.overflow = 'hidden';
        this.showViewer = true;
      },

@zzxCNCZ
Copy link
Author

zzxCNCZ commented Nov 29, 2019

i think add the following code will handle it

    clickHandler () {
      if (this.previewSrcList.length > 0) {
        // prevent body scroll
        prevOverflow = document.body.style.overflow
        document.body.style.overflow = 'hidden'
        this.showViewer = true
      }
    },

@zw8677174
Copy link

zw8677174 commented Dec 3, 2019

I get this problem too. it seems to make image-viewer run. but haven't check for i had not set preview-src-list.

看起来是为了打开 image-viewer 给body添加了overflow = 'hidden'。但是没有判断是否传了preview-src-list。没有的时候就是把滚动去掉了。这个问题还是挺影响使用的。望尽快修复。

@znspace
Copy link

znspace commented Dec 5, 2019

Also encountered this problem.

@hooray
Copy link

hooray commented Dec 5, 2019

same problem

@viulu5824
Copy link

Same problem

DevBrent referenced this issue Dec 19, 2019
* Image: Fix shield the page when preview big image

* refine

* Image:fix page scroll when use image-viewer by keyup and keydown

* add notes
@DevBrent
Copy link

DevBrent commented Dec 19, 2019

@luckyCao @island205 Please correct this regression. As soon as any image is clicked, we now permanently and irreversibly get a body { overflow: hidden } attribute added breaking page scrolling.... reproduction link from @zzxCNCZ https://codepen.io/zzxcncz/pen/LYYwOXo

@DevBrent
Copy link

DevBrent commented Dec 19, 2019

This PR resolves this bug.....
#18416

@luckyCao
Copy link
Contributor

luckyCao commented Apr 8, 2020

#19075

@cs1707
Copy link
Contributor

cs1707 commented Jan 19, 2021

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants