facebookarchive / draft-js

A React framework for building text editors.
https://draftjs.org/
MIT License
22.56k stars 2.64k forks source link

Fix selection throwing when null #3172

Open ASudre opened 1 year ago

ASudre commented 1 year ago

Before submitting a pull request, please make sure the following is done...

  1. Fork the repo and create your branch from master.
  2. If you've added code that should be tested, add tests!
  3. If you've changed APIs, update the documentation.
  4. Ensure that:
    • The test suite passes (npm test)
    • Your code lints (npm run lint) and passes Flow (npm run flow)
    • You have followed the testing guidelines
  5. If you haven't already, complete the CLA.

Please use the simple form below as a guideline for describing your pull request, and delete these instructions.

Thanks for contributing to Draft.js!


Summary

An issue occurs while using the toolbar inline plugin, an error is thrown in the method getVisibleSelectionRect because the value of the selection is null. The fix is to use ?. on the existing if test of selection.rangeCount to avoid this error.