From d007c2295ef8517274621e5bea232603b290c3cf Mon Sep 17 00:00:00 2001 From: Mendel Konikov Date: Mon, 21 Jan 2019 17:15:16 -0500 Subject: [PATCH] Fix Permalink copy on iOS --- .../client/components/PermalinkButton.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/talk-plugin-permalink/client/components/PermalinkButton.js b/plugins/talk-plugin-permalink/client/components/PermalinkButton.js index 5916b7f17..e2c286436 100644 --- a/plugins/talk-plugin-permalink/client/components/PermalinkButton.js +++ b/plugins/talk-plugin-permalink/client/components/PermalinkButton.js @@ -36,7 +36,18 @@ export default class PermalinkButton extends React.Component { }; copyPermalink = () => { - this.permalinkInput.select(); + const iOS = navigator && navigator.userAgent.match(/ipad|iphone/i); + + if (iOS) { + let range = document.createRange(); + range.selectNodeContents(this.permalinkInput); + let selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + this.permalinkInput.setSelectionRange(0, 999999); + } else { + this.permalinkInput.select(); + } try { document.execCommand('copy'); this.setState({