-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Prevent scroll jump on iOS #369
Conversation
Please merge this! 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this pull request @geraldarthur, can you also confirm if this fix works in our supported browsers? https://github.com/zenorocha/clipboard.js#browser-support
@@ -1,3 +1,4 @@ | |||
.DS_Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove this line? This should be ignored in your .gitignore_global
file.
@@ -452,15 +452,17 @@ module.exports = E; | |||
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; | |||
// Move element to the same position vertically | |||
var yPosition = window.pageYOffset || document.documentElement.scrollTop; | |||
this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition)); | |||
console.log("yPosition", yPosition); | |||
// this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove this console.log
and the commented code block?
this.selectedText = select(this.fakeElem); | ||
this.fakeElem.select(); | ||
this.fakeElem.setSelectionRange(0, this.fakeElem.value.length); | ||
this.selectedText = this.fakeElem.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The select
package already do this kind of logic https://github.com/zenorocha/select/blob/master/src/select.js#L9-L13. The difference is that it calls focus()
instead of select()
. Can you use the select package and submit a PR to it?
Thanks to @geraldarthur at #369
I went ahead and commited this so we could have this fixed faster. Thanks a lot for your work @geraldarthur. Let me know if everything is working fine for you guys on |
This fix is working great for me. Thanks to the both of you! @zenorocha @geraldarthur |
thanks so much @zenorocha! had a few deadline creep up on me yesterday, but appreciate your help. i'll test out the latest later this week. cheers! |
No, it no works for me. I use clipboardjs 1.6, on ios 10.xxx, scrolls to data-clipboard-target element when I copy/cut. I have an input element (data-clipboard-target) at the top of page (position:fixed), I scroll down, down and down to the my button copy. And after copy, It brings me to data-clipboard-target position. I don't want that. I want it no moves. |
Thanks to @geraldarthur at zenorocha#369
…Thanks to @geraldarthur at zenorocha#369" This reverts commit a9936cc.
Fixes #347
Use the
select
method onfakeElem
, instead offocus
. Passesnpm test
and is more reliable thanwindow.scrollTo
. Solution courtesy of this StackOverflow commentcc @zenorocha