Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Fix error when anchorNode is missing in editOnInput #1586

Closed
wants to merge 1 commit into from

Conversation

eldh
Copy link

@eldh eldh commented Dec 21, 2017

Fix for issue related to #1399. The fix is similar to #1407, in that it checks if anchorNode is falsy and if so bails.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@flarnie
Copy link
Contributor

flarnie commented Jan 8, 2018

Hi @eldh!
I've been reconsidering the approach used in #1407 - it's true that according to the spec, anchorNode could be null. But why would that happen? And is it always correct to return in that case?
editOnInput gets called in a variety of circumstances, and I'm not convinced that this is the right fix.
It would be helpful to have a repro case and tests to demonstrate the problem.

@eldh
Copy link
Author

eldh commented Jan 8, 2018

Yeah, I agree it feels a bit weird. I'll dig a bit deeper! 👍

@eldh
Copy link
Author

eldh commented Jan 8, 2018

As to the question of why this happens: The case here is that the editor loses focus before editOnInput is called, so global.getSelection() will not be what is expected. More specifically, we have built a user mention feature where we display (and focus) user selection ui on typing @, moving the focus immediately. It's fairly easily fixed by delaying the focus change by one tick. But the question is if draft-js should make this assumption about the global state.

If not, is it correct to return in all cases? From what I can tell, the happy case on editOnInput is that it performs a bunch of actions on the anchorNode and related nodes. But before that, it does checks to check whether it should bail (isNotTextOrElementNode, isNotTextNode) early. I'd argue that it makes sense to include this case – nodeType is null – in the bail checks. Another option would perhaps be to throw a nicer error, with explanation on how to fix?

I'm probably missing a lot of context here, not sure in which other cases editOnInput is being called and what is expected in those cases. I'd be happy to try and write a test case at least.

@eldh eldh closed this May 28, 2018
@eldh eldh deleted the edit-on-input-fix branch May 28, 2018 08:42
facebook-github-bot referenced this pull request Nov 5, 2019
…und (#2242)

Summary:
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.1 to 4.5.1.
<details>
<summary>Changelog</summary>

*Sourced from [handlebars's changelog](https://github.com/wycats/handlebars.js/blob/v4.5.1/release-notes.md).*

> ## v4.5.1 - October 29th, 2019
> Bugfixs
>
> - fix: move "eslint-plugin-compat" to devDependencies - 5e9d17f ([https://github.com/facebook/draft-js/issues/1589](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1589))
>
> Compatibility notes:
> - No compatibility issues are to be expected
>
>
> [Commits](handlebars-lang/handlebars.js@v4.5.0...v4.5.1)
>
> ## v4.5.0 - October 28th, 2019
> Features / Improvements
> - Add method Handlebars.parseWithoutProcessing ([https://github.com/facebook/draft-js/issues/1584](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1584)) - 62ed3c2
> - add guard to if & unless helpers ([https://github.com/facebook/draft-js/issues/1549](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1549))
> - show source location for the strict lookup exceptions - feb60f8
>
> Bugfixes:
> - Use objects for hash value tracking - 7fcf9d2
>
> Chore:
> - Resolve deprecation warning message from eslint while running eslint ([https://github.com/facebook/draft-js/issues/1586](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1586)) - 7052e88
> - chore: add eslint-plugin-compat and eslint-plugin-es5 - 088e618
>
> Compatibility notes:
> - No compatibility issues are to be expected
>
> [Commits](handlebars-lang/handlebars.js@v4.4.5...v4.5.0)
>
> ## v4.4.5 - October 20th, 2019
> Bugfixes:
>
> - Contents of raw-blocks must be matched with non-eager regex-matching - 8d5530e, [https://github.com/facebook/draft-js/issues/1579](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1579)
>
>
>
> [Commits](handlebars-lang/handlebars.js@v4.4.4...v4.4.5)
>
> ## v4.4.4 - October 20th, 2019
> Bugfixes:
> - fix: prevent zero length tokens in raw-blocks ([https://github.com/facebook/draft-js/issues/1577](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1577), [https://github.com/facebook/draft-js/issues/1578](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1578)) - f1752fe
>
> Chore:
> - chore: link to s3 bucket with https, add "npm ci" to build instructions - 0b593bf
>
> Compatibility notes:
> - no compatibility issues are expected
>
> [Commits](handlebars-lang/handlebars.js@v4.4.3...v4.4.4)
>
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`7ef8617`](handlebars-lang/handlebars.js@7ef8617) v4.5.1
- [`b75e3e1`](handlebars-lang/handlebars.js@b75e3e1) Update release notes
- [`5e9d17f`](handlebars-lang/handlebars.js@5e9d17f) fix: move "eslint-plugin-compat" to devDependencies
- [`b24797d`](handlebars-lang/handlebars.js@b24797d) v4.5.0
- [`a243067`](handlebars-lang/handlebars.js@a243067) Update release notes
- [`088e618`](handlebars-lang/handlebars.js@088e618) chore: add eslint-plugin-compat and eslint-plugin-es5
- [`7052e88`](handlebars-lang/handlebars.js@7052e88) Resolve deprecation warning message from eslint while running eslint ([https://github.com/facebook/draft-js/issues/1586](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1586))
- [`b8913fc`](handlebars-lang/handlebars.js@b8913fc) Add missing types for the Exception class properties ([https://github.com/facebook/draft-js/issues/1583](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1583))
- [`62ed3c2`](handlebars-lang/handlebars.js@62ed3c2) Add Handlebars.parseWithoutProcessing ([https://github.com/facebook/draft-js/issues/1584](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1584))
- [`7fcf9d2`](handlebars-lang/handlebars.js@7fcf9d2) Use objects for hash value tracking
- Additional commits viewable in [compare view](handlebars-lang/handlebars.js@v4.1.1...v4.5.1)
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=handlebars&package-manager=npm_and_yarn&previous-version=4.1.1&new-version=4.5.1)](https://help.github.com/articles/configuring-automated-security-fixes)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/draft-js/network/alerts).

</details>
Pull Request resolved: #2242

Differential Revision: D18314832

Pulled By: mrkev

fbshipit-source-id: a021417222e0eddabc7816eeb0468f2c91ace9d9
mmissey referenced this pull request in mmissey/draft-js Mar 24, 2020
…und (facebookarchive#2242)

Summary:
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.1 to 4.5.1.
<details>
<summary>Changelog</summary>

*Sourced from [handlebars's changelog](https://github.com/wycats/handlebars.js/blob/v4.5.1/release-notes.md).*

> ## v4.5.1 - October 29th, 2019
> Bugfixs
>
> - fix: move "eslint-plugin-compat" to devDependencies - 5e9d17f ([https://github.com/facebook/draft-js/issues/1589](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1589))
>
> Compatibility notes:
> - No compatibility issues are to be expected
>
>
> [Commits](handlebars-lang/handlebars.js@v4.5.0...v4.5.1)
>
> ## v4.5.0 - October 28th, 2019
> Features / Improvements
> - Add method Handlebars.parseWithoutProcessing ([https://github.com/facebook/draft-js/issues/1584](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1584)) - 62ed3c2
> - add guard to if & unless helpers ([https://github.com/facebook/draft-js/issues/1549](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1549))
> - show source location for the strict lookup exceptions - feb60f8
>
> Bugfixes:
> - Use objects for hash value tracking - 7fcf9d2
>
> Chore:
> - Resolve deprecation warning message from eslint while running eslint ([https://github.com/facebook/draft-js/issues/1586](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1586)) - 7052e88
> - chore: add eslint-plugin-compat and eslint-plugin-es5 - 088e618
>
> Compatibility notes:
> - No compatibility issues are to be expected
>
> [Commits](handlebars-lang/handlebars.js@v4.4.5...v4.5.0)
>
> ## v4.4.5 - October 20th, 2019
> Bugfixes:
>
> - Contents of raw-blocks must be matched with non-eager regex-matching - 8d5530e, [https://github.com/facebook/draft-js/issues/1579](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1579)
>
>
>
> [Commits](handlebars-lang/handlebars.js@v4.4.4...v4.4.5)
>
> ## v4.4.4 - October 20th, 2019
> Bugfixes:
> - fix: prevent zero length tokens in raw-blocks ([https://github.com/facebook/draft-js/issues/1577](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1577), [https://github.com/facebook/draft-js/issues/1578](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1578)) - f1752fe
>
> Chore:
> - chore: link to s3 bucket with https, add "npm ci" to build instructions - 0b593bf
>
> Compatibility notes:
> - no compatibility issues are expected
>
> [Commits](handlebars-lang/handlebars.js@v4.4.3...v4.4.4)
>
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`7ef8617`](handlebars-lang/handlebars.js@7ef8617) v4.5.1
- [`b75e3e1`](handlebars-lang/handlebars.js@b75e3e1) Update release notes
- [`5e9d17f`](handlebars-lang/handlebars.js@5e9d17f) fix: move "eslint-plugin-compat" to devDependencies
- [`b24797d`](handlebars-lang/handlebars.js@b24797d) v4.5.0
- [`a243067`](handlebars-lang/handlebars.js@a243067) Update release notes
- [`088e618`](handlebars-lang/handlebars.js@088e618) chore: add eslint-plugin-compat and eslint-plugin-es5
- [`7052e88`](handlebars-lang/handlebars.js@7052e88) Resolve deprecation warning message from eslint while running eslint ([https://github.com/facebook/draft-js/issues/1586](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1586))
- [`b8913fc`](handlebars-lang/handlebars.js@b8913fc) Add missing types for the Exception class properties ([https://github.com/facebook/draft-js/issues/1583](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1583))
- [`62ed3c2`](handlebars-lang/handlebars.js@62ed3c2) Add Handlebars.parseWithoutProcessing ([https://github.com/facebook/draft-js/issues/1584](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1584))
- [`7fcf9d2`](handlebars-lang/handlebars.js@7fcf9d2) Use objects for hash value tracking
- Additional commits viewable in [compare view](handlebars-lang/handlebars.js@v4.1.1...v4.5.1)
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=handlebars&package-manager=npm_and_yarn&previous-version=4.1.1&new-version=4.5.1)](https://help.github.com/articles/configuring-automated-security-fixes)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/draft-js/network/alerts).

</details>
Pull Request resolved: facebookarchive#2242

Differential Revision: D18314832

Pulled By: mrkev

fbshipit-source-id: a021417222e0eddabc7816eeb0468f2c91ace9d9
vilemj-Viclick referenced this pull request in kontent-ai/draft-js Jul 16, 2020
…und (facebookarchive#2242)

Summary:
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.1 to 4.5.1.
<details>
<summary>Changelog</summary>

*Sourced from [handlebars's changelog](https://github.com/wycats/handlebars.js/blob/v4.5.1/release-notes.md).*

> ## v4.5.1 - October 29th, 2019
> Bugfixs
>
> - fix: move "eslint-plugin-compat" to devDependencies - 5e9d17f ([https://github.com/facebook/draft-js/issues/1589](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1589))
>
> Compatibility notes:
> - No compatibility issues are to be expected
>
>
> [Commits](handlebars-lang/handlebars.js@v4.5.0...v4.5.1)
>
> ## v4.5.0 - October 28th, 2019
> Features / Improvements
> - Add method Handlebars.parseWithoutProcessing ([https://github.com/facebook/draft-js/issues/1584](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1584)) - 62ed3c2
> - add guard to if & unless helpers ([https://github.com/facebook/draft-js/issues/1549](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1549))
> - show source location for the strict lookup exceptions - feb60f8
>
> Bugfixes:
> - Use objects for hash value tracking - 7fcf9d2
>
> Chore:
> - Resolve deprecation warning message from eslint while running eslint ([https://github.com/facebook/draft-js/issues/1586](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1586)) - 7052e88
> - chore: add eslint-plugin-compat and eslint-plugin-es5 - 088e618
>
> Compatibility notes:
> - No compatibility issues are to be expected
>
> [Commits](handlebars-lang/handlebars.js@v4.4.5...v4.5.0)
>
> ## v4.4.5 - October 20th, 2019
> Bugfixes:
>
> - Contents of raw-blocks must be matched with non-eager regex-matching - 8d5530e, [https://github.com/facebook/draft-js/issues/1579](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1579)
>
>
>
> [Commits](handlebars-lang/handlebars.js@v4.4.4...v4.4.5)
>
> ## v4.4.4 - October 20th, 2019
> Bugfixes:
> - fix: prevent zero length tokens in raw-blocks ([https://github.com/facebook/draft-js/issues/1577](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1577), [https://github.com/facebook/draft-js/issues/1578](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1578)) - f1752fe
>
> Chore:
> - chore: link to s3 bucket with https, add "npm ci" to build instructions - 0b593bf
>
> Compatibility notes:
> - no compatibility issues are expected
>
> [Commits](handlebars-lang/handlebars.js@v4.4.3...v4.4.4)
>
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`7ef8617`](handlebars-lang/handlebars.js@7ef8617) v4.5.1
- [`b75e3e1`](handlebars-lang/handlebars.js@b75e3e1) Update release notes
- [`5e9d17f`](handlebars-lang/handlebars.js@5e9d17f) fix: move "eslint-plugin-compat" to devDependencies
- [`b24797d`](handlebars-lang/handlebars.js@b24797d) v4.5.0
- [`a243067`](handlebars-lang/handlebars.js@a243067) Update release notes
- [`088e618`](handlebars-lang/handlebars.js@088e618) chore: add eslint-plugin-compat and eslint-plugin-es5
- [`7052e88`](handlebars-lang/handlebars.js@7052e88) Resolve deprecation warning message from eslint while running eslint ([https://github.com/facebook/draft-js/issues/1586](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1586))
- [`b8913fc`](handlebars-lang/handlebars.js@b8913fc) Add missing types for the Exception class properties ([https://github.com/facebook/draft-js/issues/1583](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1583))
- [`62ed3c2`](handlebars-lang/handlebars.js@62ed3c2) Add Handlebars.parseWithoutProcessing ([https://github.com/facebook/draft-js/issues/1584](https://github-redirect.dependabot.com/wycats/handlebars.js/issues/1584))
- [`7fcf9d2`](handlebars-lang/handlebars.js@7fcf9d2) Use objects for hash value tracking
- Additional commits viewable in [compare view](handlebars-lang/handlebars.js@v4.1.1...v4.5.1)
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=handlebars&package-manager=npm_and_yarn&previous-version=4.1.1&new-version=4.5.1)](https://help.github.com/articles/configuring-automated-security-fixes)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/facebook/draft-js/network/alerts).

</details>
Pull Request resolved: facebookarchive#2242

Differential Revision: D18314832

Pulled By: mrkev

fbshipit-source-id: a021417222e0eddabc7816eeb0468f2c91ace9d9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants