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

[Bug] Cannot extend MUTABLE entity range in v0.10.5, works in v0.10.4 #1642

Closed
alexlatchford opened this issue Feb 7, 2018 · 4 comments
Closed

Comments

@alexlatchford
Copy link

What is the current behavior?

In v0.10.5 if you place the cursor at the end of a MUTABLE entity and type it does not expand the entity range. If you type in the middle it does.

v0 10 5

Check the behaviour of the "Batman" entity in the entity example: https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/entity/entity.html

What is the expected behavior?

In v0.10.4 if you type at the end or the middle of the entity range it expands the entity range. This is the desired behaviour I'm looking for.

v0 10 4

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

Broken in > v0.10.5 and in current master. Works fine in v0.10.4 and below I think.


I've had a quick look through the commit range for v0.10.4...v0.10.5 but nothing immediately jumps out at me.

Not pressing I've just reverted to v0.10.4 for the meantime.

@alexlatchford alexlatchford changed the title [Bug] Cannot append to MUTABLE entity in v0.10.5 [Bug] Cannot append to MUTABLE entity in v0.10.5, works in v0.10.4 Feb 7, 2018
@alexlatchford alexlatchford changed the title [Bug] Cannot append to MUTABLE entity in v0.10.5, works in v0.10.4 [Bug] Cannot extend MUTABLE entity range in v0.10.5, works in v0.10.4 Feb 7, 2018
@thibaudcolas
Copy link
Contributor

thibaudcolas commented Feb 7, 2018

Hey @alexlatchford, I think this is the following (intentional) change from the 0.10.5 changelog:

Fix issue where typing at the end of a link caused the link to continue. (Ian Jones in d16833b)

You can see the reasoning for this change over at #430 and #510.

@alexlatchford
Copy link
Author

alexlatchford commented Feb 7, 2018

Great thanks @thibaudcolas, that indeed looks like the issue.

Trying to track down what actually swayed the decision as #430 & #510 seem like they weren't the tipping point. Looks like the author potentially works internal to Facebook, cannot seem to find the PR for that particular change. Anyone from the core team care to weigh in?

My use case for extending the mutable entity range is for a mention/tag autocomplete. So the user types @ or # and then keeps typing, we highlight the range as though it's an entity and use the text after the token to populate an inline autocomplete. Any thoughts on how to achieve that in a post-v0.10.5 world?

screen shot 2018-02-07 at 13 48 05

@ddelrio1986
Copy link

I think that extending the entity automatically is bad. You should be able to do it yourself in handleBeforeInput. If it automatically extends how would a user break out of that? If doing the extension manually you can decide when to allow the user to break out of the entity (maybe a space or something would cause it). Also the behavior before v0.10.5 was a bit inconsistent because typing at the beginning did not add to the entity.

@alexlatchford
Copy link
Author

True that makes sense, I just tried the underlying problem with links and the behaviour in v0.10.5+ is definitely preferred!

Thanks for the tip about handleBeforeInput I'll give that a try and see if it does the job. Keep up the good work on this project it's been fantastic for us!

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

No branches or pull requests

3 participants