question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto-resize changes pageOffsetY in Chrome when textarea is near bottom of window

See original GitHub issue

Describe the bug

When a b-form-textarea with more lines than it’s rows attribute is edited, it can cause the window to scroll upwards. To me, it looks like this happens because the textarea shrinks in height due to height being set to auto in the on-change handler in form-textarea.js:176. If the window’s bottom is now higher than the screen’s bottom, the browser automatically scrools upwards to fill the empty space. Now, the textarea is reset in it’s height, but the new scroll position is already set and doesn’t change back.

Please note that I have only observed this bug in Chrome and could not reproduce it in Firefox.

Steps to reproduce the bug

  1. Create a b-form-textarea and fill it with so many lines, that rows <= # lines <= max-rows. The textarea must overflow one of it’s parents and cause a scroll bar.
  2. Scroll to the very bottom of the overflowed parent.
  3. Edit the textarea. The parent should now have scrolled up.

Expected behavior

The scrolling position should not change whenever editing a textarea, unless it is to display a new line that was added that would have otherwise been off-screen.

Versions

Libraries: (See CodeSandbox below)

  • BootstrapVue: 2.16.0
  • Bootstrap: 4…5.2
  • Vue: 2.6.0

Environment:

  • Device: PC
  • OS: Windows 10
  • Browser: Chrome (works in Firefox!)
  • Version: 84.0.4147.135

Demo link

See this CodeSandbox. Make sure to follow the steps above to observe the issue.

Additional context

I came across this bug in vabene1111/recipes and opened an issue there already. That issue contains a GIF showing the behavior in the app that might be helpful in case my description wasn’t understandable enough.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Hiwscommented, Sep 12, 2020

I’ve just tested it in Firefox 79 & 80.0.1. Chrome 85 and Chromium Edge 85. It appears to be an issue on all of them. However, i remember testing it in Firefox when the issue was made and didn’t experience any issues then. However it might’ve been an old version since i rarely use Firefox.

The screencap below is in Firefox. BsM6itf 1

That’s atleast the case if i understand the issue correctly.

1reaction
Hiwscommented, Sep 1, 2020

Looks like you were correct about it being a separate issue. I’ve opened another issue to track it: https://github.com/bootstrap-vue/bootstrap-vue/issues/5715 Thanks for helping out 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to stop window jumping when typing in autoresizing ...
Save the scrollLeft , scrollTop values, and then restore them after resizing the textarea: function resize () { var scrollLeft = window.
Read more >
Window.pageYOffset - Web APIs | MDN
The read-only Window property pageYOffset is an alias for scrollY; ... the document is located at the top edge of the window's content...
Read more >
Window resizeTo() Method - W3Schools
Open a new window, and resize it to 300 x 300: function openWin() { ... The resizeTo() method resizes a window to a...
Read more >
Safari Technology Preview Release Notes - Apple Developer
If you already have Safari Technology Preview installed, you can update in the Software Update pane of System Preferences on macOS Monterey, or...
Read more >
website scrolls down when going to the page next js - You.com
Lower Decreases the frequency the app appears ... I found this script tag near the bottom of the page ... Chrome changed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found