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

Safari Scrolls to Top on Focus #238

Closed
nick-bigger opened this issue Mar 7, 2023 · 5 comments
Closed

Safari Scrolls to Top on Focus #238

nick-bigger opened this issue Mar 7, 2023 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@nick-bigger
Copy link

When clicking on the JSON Editor near the end of a long JSON document, the browser force scrolls back to the top of the input requiring scrolling back down. I've managed to reproduce this in the Codesandbox for the React and Vue implementations:

jsonEditor

To Reproduce:
I have created a fork of the linked React implementation just to add in a long example JSON, but you can reproduce this in the original linked React implementation as well if you'd like (you just need to add in enough JSON to need to scroll).

  1. Open https://codesandbox.io/s/svelte-jsoneditor-react-forked-ghipor?file=/src/App.js:301-7438
  2. Scroll to bottom of JSON Editor
  3. Click on any structure
  4. Observe browser force scrolled to the top

Additional Details

  • After this happens once, it doesn't happen until the page is refreshed.
  • This only seems to occur in Safari on Desktop (I've tested and can't repro in Chrome or Safari for iOS)

Thank you so much ! We love this library and are hoping for a fix for this as we use it for JSON inputs all over our application.

@nick-bigger nick-bigger changed the title Safari Scrolls to Top on Focus (React, Vue) Safari Scrolls to Top on Focus Mar 7, 2023
@josdejong
Copy link
Owner

Thanks for reporting. The editor has a hidden input field which is used to capture quick keys like arrows to navigate through the contents of the editor. When you click somewhere inside the editor, this input field is given focus. This input field has a class name jse-hidden-input-label, and it is styled with position: fixed, right: 0; top: 0; width: 0; height: 0;.

Anyone able to debug why Safari scrolls to top when giving this element focus and find a way to prevent Safari from scrolling up? (Chrome and Firefox do not do that).

@josdejong josdejong added bug Something isn't working help wanted Extra attention is needed labels Mar 9, 2023
@nick-bigger
Copy link
Author

hi there ! just bumping this as it has been few months with no movement - this causes us daily issues and we haven't found any work around :(

@josdejong
Copy link
Owner

I think I have fixed this via 20129f8. Apparently Safari does do something special to the hidden input field when it has a width and height of zero 🤔 .

@nick-bigger
Copy link
Author

Thank you so much ! I can't wait to test 😁 we really appreciate all of your hard work on this awesome package

@josdejong
Copy link
Owner

josdejong commented May 3, 2023

Fixed now in v0.17.2

Thank you so much ! I can't wait to test 😁 we really appreciate all of your hard work on this awesome package

Thanks! You're welcome. If the project is so important to you, please consider sponsoring me to ensure I can keep maintaining and improving the library 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants