-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(clipboard): scroll position changing while copying on some browsers #20073
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
Conversation
The clipboard module works by creating a `textarea` dynamically, focusing it and copying its content. In order to prevent it from affecting the page layout, we put it at `-999em` off-screen, but the problem is that some browsers will try to move it into the view on focus by scrolling up. These changes use `position: fixed` and anchor the textarea to the top of the page so vertically it's within the viewport.
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.
LGTM
Hi @crisbeto, srry I am late to this :( did you checked if the fix is working in IE11? There is same issue in See issue here: angular/angular#37796 |
I was testing against IE11 specifically when I saw the issue. This won't fix angular.io since they aren't using the CDK though. |
@crisbeto Ok 💯 It would be great if you can give any suggestions to solution in the other issue, because I tried to apply the code here to |
…rs (#20073) The clipboard module works by creating a `textarea` dynamically, focusing it and copying its content. In order to prevent it from affecting the page layout, we put it at `-999em` off-screen, but the problem is that some browsers will try to move it into the view on focus by scrolling up. These changes use `position: fixed` and anchor the textarea to the top of the page so vertically it's within the viewport. (cherry picked from commit a6f1a33)
…a creation This commit simplifies the creation of the temporary, hidden `<textarea>` element used by `CopierService` by switching from absolute to fixed positioning and not requiring page's scroll offset. It also makes the following minor improvements: - Make the element invisible (via `opacity: 0`). - Instruct screen-readers to ignore the element (via `aria-hidden: true`). NOTE: These improvements are based on Angular CDK's [PendingCopy][1] class and the changes proposed in PR angular/components#20073. [1]: https://github.com/angular/components/blob/89b5fa89d1437c3054c5/src/cdk/clipboard/pending-copy.ts
…a creation (#38244) This commit simplifies the creation of the temporary, hidden `<textarea>` element used by `CopierService` by switching from absolute to fixed positioning and not requiring page's scroll offset. It also makes the following minor improvements: - Make the element invisible (via `opacity: 0`). - Instruct screen-readers to ignore the element (via `aria-hidden: true`). NOTE: These improvements are based on Angular CDK's [PendingCopy][1] class and the changes proposed in PR angular/components#20073. [1]: https://github.com/angular/components/blob/89b5fa89d1437c3054c5/src/cdk/clipboard/pending-copy.ts PR Close #38244
…a creation (#38244) This commit simplifies the creation of the temporary, hidden `<textarea>` element used by `CopierService` by switching from absolute to fixed positioning and not requiring page's scroll offset. It also makes the following minor improvements: - Make the element invisible (via `opacity: 0`). - Instruct screen-readers to ignore the element (via `aria-hidden: true`). NOTE: These improvements are based on Angular CDK's [PendingCopy][1] class and the changes proposed in PR angular/components#20073. [1]: https://github.com/angular/components/blob/89b5fa89d1437c3054c5/src/cdk/clipboard/pending-copy.ts PR Close #38244
…a creation (angular#38244) This commit simplifies the creation of the temporary, hidden `<textarea>` element used by `CopierService` by switching from absolute to fixed positioning and not requiring page's scroll offset. It also makes the following minor improvements: - Make the element invisible (via `opacity: 0`). - Instruct screen-readers to ignore the element (via `aria-hidden: true`). NOTE: These improvements are based on Angular CDK's [PendingCopy][1] class and the changes proposed in PR angular/components#20073. [1]: https://github.com/angular/components/blob/89b5fa89d1437c3054c5/src/cdk/clipboard/pending-copy.ts PR Close angular#38244
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The clipboard module works by creating a
textarea
dynamically, focusing it and copying its content. In order to prevent it from affecting the page layout, we put it at-999em
off-screen, but the problem is that some browsers will try to move it into the view on focus by scrolling up.These changes use
position: fixed
and anchor the textarea to the top of the page so vertically it's within the viewport.