question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inserting content through an extension causes a duplication issue.

See original GitHub issue

Hi, I’m working on a chrome extension that lets you input text through it. Unfortunately Draft.js breaks when inputting in a standard way.

Steps to reproduce:

  1. Load http://facebook.github.io/draft-js/
  2. Open Chrome Dev Tools
  3. Select the Draft.js input box so that the input caret is present
  4. execute document.execCommand("insertHTML", false, "X"); in the dev tools console

Result expected: X is added to the input box

Actual result: X is added to the input box twice. You’re able to delete one of the instances, but the other one is undeletable but is selectable.

Note: Once at least one character has been typed into the Draft.js input the command works as expected.

Screenshot of the result: screen shot 2016-02-22 at 8 09 26 pm

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
grzeczkocommented, May 3, 2016

Here’s the code:

if (document.querySelectorAll('span[data-text="true"]').length === 0) { document.execCommand("insertHTML", false, "X"); document.execCommand("undo", false); } else { document.execCommand("insertHTML", false, "X"); }

It will check to see if you have entered the first character. If you did, it’ll do the undo execCommand and remove the extra X. The else will just insertHTML since it won’t insert any extras once characters have been entered.

0reactions
tylercraftcommented, Oct 22, 2016

Looks like a workaround was found, so I’m going to close this out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inserting text with execCommand causes a duplication issue
I'm working on a Firefox extension that inserts Polish characters to any text field using keyboard shortcuts. It's working for all text ......
Read more >
Seeing Double: Your SEO Guide to Duplicate Content
Duplicate content is an incredibly common SEO issue. But what is it? Why is it bad? And what can you do about it?...
Read more >
How To Identify And Fix Duplicate Content Issues With SEO ...
The detailed guide on how to identify and fix duplicate content issues. You'll learn what duplicate content is, why it occurs, and how...
Read more >
Duplicate Content: 5 Myths and 5 Facts About How It Impacts ...
“Duplicate content on a site is not grounds for action on that site unless it appears that the intent of the duplicate content...
Read more >
Duplicate Content: Why does it happen and how to fix issues
Duplicate content is content that appears on the Internet in more than one place. That “one place” is defined as a location with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found