Giter VIP home page Giter VIP logo

ld-emoji's People

Contributors

svnm avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

juularthur

ld-emoji's Issues

Cannot read property 'length' of undefined when pick emoji

So this is quite interesting bug! Sometimes when you click the emoji, this bug appear:

Uncaught TypeError: Cannot read property 'length' of undefined
    at insertTextIntoContentState (insertTextIntoContentState.js:27)
    at Object.replaceText (DraftModifier.js:54)
    at Object.insertText (DraftModifier.js:59)
    at _default.addEmoji (emojiButton.js:67)
    at _default.onEmojiSelect (Picker.js:94)
    at Object.ReactErrorUtils.invokeGuardedCallback (ReactErrorUtils.js:70)
    at executeDispatch (EventPluginUtils.js:85)
    at Object.executeDispatchesInOrder (EventPluginUtils.js:108)
    at executeDispatchesAndRelease (EventPluginHub.js:43)
    at executeDispatchesAndReleaseTopLevel (EventPluginHub.js:54)

At I looked into the code,

      var emoji = e.target.alt; // --> the bug happens when this is undefined
      this.props.onEmojiSelected(emoji); 

So for example, the html layout is this:

<span class="ld-emoji hucMvd" role="presentation"><img class="emojione" alt="๐Ÿ˜„" title=":smile:" src="https://cdn.jsdelivr.net/emojione/assets/png/1f604.png?v=2.2.7"></span>

When you click on the padding spaces between span and img tag, the registered event.target is span not img(so alt will be undefined).
Fix is quite simple, use currentTarget rather than target. I will submit pull request when I have more time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.