Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorations should not be mutable #2634

Closed
gdehmlow opened this issue Mar 7, 2019 · 4 comments
Closed

Decorations should not be mutable #2634

gdehmlow opened this issue Mar 7, 2019 · 4 comments

Comments

@gdehmlow
Copy link

gdehmlow commented Mar 7, 2019

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

Bug

What's the current behavior?

Take the search highlighting example. Enter a search term. Select the end of the highlighted word and type.. the highlight continues as the decoration is appended to:

decorationbug

Likewise, if you hit enter, both lines become highlighted:

decorationbug2

What's the expected behavior?

Modifying decorated text should re-evaluate the decorations and ensure that they are valid.

@gdehmlow gdehmlow changed the title Decorations should not be butable Decorations should not be mutable Mar 7, 2019
@gdehmlow
Copy link
Author

gdehmlow commented Mar 7, 2019

As an amendment to this issue, it seems that sometimes decorations can come back from the grave. See this fiddle: https://jsfiddle.net/710djobp/8/

weird decorate issue

The idea is that roughly 50% of the time, when a character is entered, the text of the current node should turn red. As we can see, decorateNode is only ever firing for the current block being typed in (as we expect).

But the text for other nodes will sometimes turn red.. even though they aren't having their respective decorateNode methods called!

@isubasti
Copy link
Contributor

isubasti commented Mar 8, 2019

@gdehmlow not sure about how we can fix the original issue but the amendment is actually a non issue. it looks like it come back from the grave because it's decorating document which is not a block but a node as well. if you do:

if (node.object !== 'block') return [];

at the very start of decorateNode function then you won't get that issue

@imaGuru
Copy link

imaGuru commented May 31, 2019

What's the expected behavior?
Modifying decorated text should re-evaluate the decorations and ensure that they are valid.

IMHO that is your job. You should reevaluate decorations in onChange hook

Decorations should mutate it's focus and anchor points when edited (like they do now). This is actually very desirable and I am using this functionality to mark sections of my document. So when a user modifies a section of the document I still maintain the correct start and end points of the section. The same applies to collaborative cursors - e.g. if you edit inside someone's selection

Also the bug described doesn't seem to exist anymore in the recent annotation update

@ianstormtaylor ianstormtaylor mentioned this issue Nov 6, 2019
@ianstormtaylor
Copy link
Owner

As of #3093 (which was just merged), I believe this issue is no longer applicable, because a lot has changed. I'm going through and closing out any potential issues that are not out of date with the overhaul. Thanks for understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants