Skip to content
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

fix: Support experimental copy & paste in IE 11 #349

Merged
merged 2 commits into from Aug 14, 2019

Conversation

@SilentGert
Copy link
Contributor

SilentGert commented Aug 13, 2019

Fixes #348

I added a fallback to use window.clipboardData when event.clipboardData is not defined, which is the case in IE 11, when the new experimental copy and paste feature is used.

Following the investigation in this PR, I disabled the new cut, copy, paste mechanism for browsers whose events do not have clipboardData attached to the event. This concerns mostly IE.

In IE 11 the clipboardData object is attached to window and only supports mime type text. Therefore, the new mechanism will not work anyway as it makes use of two different mime types.

How to test?

  1. Open IE 11
  2. Go to https://react-mentions.wolf-pack.now.sh
  3. Scroll to the EXPERIMENTAL section
  4. Copy the text with mentions
  5. Paste it in the next input
@now

This comment has been minimized.

Copy link

now bot commented Aug 13, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://react-mentions-git-bugfix-348-copy-and-paste-ie11.wolf-pack.now.sh

@SilentGert

This comment has been minimized.

Copy link
Contributor Author

SilentGert commented Aug 13, 2019

Okay, just adding the fallback doesn't solve the problem. Now I'm running into other error message when accessing setData and getData.

@SilentGert SilentGert changed the title #348 Fallback to window.clipboardData when event.clipboardData is not… Support experimental copy & paste in IE 11 Aug 13, 2019
@SilentGert SilentGert changed the title Support experimental copy & paste in IE 11 WIP: Support experimental copy & paste in IE 11 Aug 13, 2019
@SilentGert

This comment has been minimized.

Copy link
Contributor Author

SilentGert commented Aug 13, 2019

It looks like IE 11 has a problem with the formats text/react-mentions and text/plain. Just using text as format doesn't throw any errors.

While looking for more details about the problem I found this ticket: ProseMirror/prosemirror#325

It looks like we would need some extra handling to support the new feature in IE 11.
Even if you look at libraries like https://github.com/sudodoki/copy-to-clipboard they have no special handling for the format.

Now that makes me wonder if we should just disable the feature for IE 11 by checking for the existence of clipboardData:

handleCopy(event) {
    if (event.target !== this.inputRef) {
      return
    }
    if (!event.clipboardData) {
      // In case of IE 11 or older which do not support copying different formats
      return
    }

Then we stick to the browsers default behaviour for now.

@frontendphil @jfschwarz Any opinion?

@SilentGert SilentGert force-pushed the bugfix/348-copy-and-paste-ie11 branch from 45cca86 to 851e8fe Aug 14, 2019
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Aug 14, 2019

Codecov Report

Merging #349 into master will increase coverage by 0.29%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #349      +/-   ##
==========================================
+ Coverage   76.82%   77.11%   +0.29%     
==========================================
  Files          22       22              
  Lines         630      638       +8     
  Branches       95       98       +3     
==========================================
+ Hits          484      492       +8     
  Misses        145      145              
  Partials        1        1
Impacted Files Coverage Δ
src/MentionsInput.js 67.91% <100%> (+0.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c69008...b2b7d1a. Read the comment docs.

@SilentGert SilentGert changed the title WIP: Support experimental copy & paste in IE 11 Support experimental copy & paste in IE 11 Aug 14, 2019
Copy link
Contributor

frontendphil left a comment

I think aiming for modern browsers and ditching IE 11 is ok 👍

@frontendphil frontendphil changed the title Support experimental copy & paste in IE 11 fix: Support experimental copy & paste in IE 11 Aug 14, 2019
@frontendphil frontendphil merged commit 08deded into master Aug 14, 2019
4 checks passed
4 checks passed
codecov/patch 100% of diff hit (target 76.82%)
Details
codecov/project 77.11% (+0.29%) compared to 3c69008
Details
now Deployment has completed
Details
qa-publish-release Workflow: qa-publish-release
Details
@frontendphil frontendphil deleted the bugfix/348-copy-and-paste-ie11 branch Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.