-
Notifications
You must be signed in to change notification settings - Fork 917
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
Window is scrolled to top after paste #394
Comments
This might have to do with how focus events are handled |
Any solution? |
me too.
@alexkrolick How to deal with the bug? |
Same here. Looking forward to a solution. |
My temp solution: // Clipboard.js
public onPaste(e) {
if (e.defaultPrevented || !this.quill.isEnabled()) return;
const range = this.quill.getSelection();
let delta = new Delta().retain(range.index);
let scrollTop = 0;
+ const container = document.querySelector(this.options.container);
+ if (container) {
+ scrollTop = container.scrollTop;
+ }
this.container.focus();
const that = this;
this.quill.selection.update((Quill as any).sources.SILENT);
setTimeout(() => {
delta = delta.concat(this.convert()).delete(range.length);
that.quill.updateContents(delta, (Quill as any).sources.USER);
// range.length contributes to delta.length()
that.quill.setSelection(delta.length() - range.length, (Quill as any).sources.SILENT);
that.quill.focus();
container.scrollTop = scrollTop;
}, 1);
}
// config
clipboard: {
// bump top bug
+ container: 'html',
}, |
@alexkrolick This does appear to be related to focus events, but I am investigating this for my app and it might be caused by css for some. I will get back to this thread with my findings. |
My findings are that this is not an issue with Quill or React Quill, but simply a CSS issue. Using You will see that the HTML element (different for everyone) that surrounds the Quill editor must have a set height of some sort, and likewise the div with the .app {
height: 400px;
}
.quill {
height: 100%;
} Please Note: The HTML around the React-Quill is important, as the CSS must work in a way where the Final Thoughts:
I am willing to help here if anyone has questions. Before you ask, please verify that your CSS and HTML match my example as best as possible (on my app its more complicated but I still follow the rules of the static height wrapper and the |
Hi @camsjams , Any suggestions? Thanks! |
Hopefully we can figure this out! In your example on codesandbox I see that the cursor stays at the bottom even after paste or heading changes, as expected. I've tested in latest Firefox, Chrome, and Chromium. What browser are you testing on? |
Hi, Thanks. |
I commented this on an issue on the quilljs github, but same thing can be applied here.
it fixed the problem for me. try it out. |
我也遇到了这个问题。请问如何解决? 我也遇到了这个问题。请问如何解决? I can manually modify the scroll bar by listening to the paste event. Although it can be executed, it will eventually be covered by unknown problems and return to the top. |
Hi @camsjams , |
现在我解决了这个问题: Now I've solved the problem: |
you should not use left: 50% top: 50%, just position: fixed will do. |
Any update on this please? |
It very much is :-) This is not a react-quill issue, its a Quill issue. A simple search will show lots of threads on this across github and SO. There are 2 connected issues: scroll and flicker. Scroll is solved by setting In my case,
This is all that is required. No complex JS required. Tested on Chrome, FF, Opera, Vivaldi, Brave & Edge. References:
|
Adding But according to this reference slab/quill#2027 , I've found two options which works for me:
|
Not using React (using native JS Quill), but issue in my case was in the fact that I had set
to outer container, not to |
This worked like a charm, thank you. Hyperlinks and pasting were both causing a lot of trouble until changing my max-height from the parent container to |
This issue seems mostly realated to CSS and DOM structure. I've prepared demo/solutions. Link: https://codesandbox.io/s/react-quill-editor-auto-grow-height-okikc0 |
To reproduce,
This problem doesn't allow to use the editor for lots of content and isn't reproducible at pure Quill.
React-Quill version
The text was updated successfully, but these errors were encountered: