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

v0.11 - Decorator component with a href on an Anchor causes caret placement issues & dies on deletion #2133

@glenn-allen

Description

@glenn-allen

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When creating a decorator component that returns an Anchor with a href the editor caret will jump to the start of the decorated component after the second character match.

When deleting the final character of the decorated component the Draft editor will crash.

decorator-anchor-480

A simple codesandbox example can be found here:
https://codesandbox.io/s/draft-js-v011-hash-with-link-example-yuiod

Some of my observations are as follows:

  • Removing the href from the anchor will no longer result in the caret errors or crashing.
  • In Draft v0.10.5 whenever a decorated component's match changes it will have its render method called.
  • In Draft v0.11 the render method is only called when the match is first created, when it's 'exited' or when backspace is pressed.

This behaviour would cause issues with components that rely on the matched string for some of their properties. For example creating a link when the text matches a URL (such as Draft JS Plugins' Linkify plugin).

Those examples can be found here:

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

  • Draft.js v0.11 (worked in v0.10.5)
  • Safari v12.1 & Chrome v75

Note: Firefox does not crash and appears to work OK in this example, however its render method isn't called when the match changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions