0

When a user has refused a clipboard access prompt, the message is not showing while next copy attempts, until the page will be reloaded. Is there a way to call the prompt manually without the page reload?

I am using React with copy-to-clipboard 3.3.1 npm package. According to the Niet the Dark Absol's advice, my copy function looks like

copyToClipboard(phone: string) {
    copy(phone, {
        format: 'text/plain',
        onCopy: (clipboardData: DataTransfer) => {
            const copiedPhone = clipboardData.getData('text/plain');
            if (copiedPhone === phone) {
                this.setState({showMessage: true});
            }
        }
    });
}

Means that I show 'Success' message when text was copied

  • 1
    That would rather defeat the point of allowing the user to reject your request in the first place. When is it that you request this permission? You should be able to detect that permission was denied, and provide some UI explaining this and that the user should reload to grant permission instead. – Niet the Dark Absol Oct 13 '20 at 09:52
  • Thanks, Niet the Dark Absol. I thought about It. I just wanted to make sure that there are no other variants. – Andrii Yeromenko Oct 13 '20 at 10:13
  • Are you trying to use the cut, copy or paste for `document.execCommand()` method or trying to use the `read(), write()` method for a clipboard? Can you please try to share your sample code for the clipboard access prompt? With that, we can try to understand what you are actually trying. Then we can try to check for the issue and then we can try to provide suggestions. Thanks for your understanding. – Deepak-MSFT Oct 14 '20 at 02:16
  • I've updated the question body with a code sample. – Andrii Yeromenko Oct 15 '20 at 06:03
  • I agree with the suggestion given by the **Niet the Dark Absol**. You can save the user choice and when the user again tries to copy again then try to inform the user for refreshing the page can be the possible solution here. – Deepak-MSFT Oct 16 '20 at 08:34

0 Answers0