ember-mobiledoc-editor icon indicating copy to clipboard operation
ember-mobiledoc-editor copied to clipboard

Use a stable key to guard against data loop

Open ef4 opened this issue 8 years ago • 0 comments

The data-loop defenses in the mobiledoc-editor component (_localMobiledoc and _upstreamMobileDoc) aren't sufficient to guard against many possible data loops, so it's easy to lose cursor position.

We could use an explicit document key/id instead. In practice, there is usually a good key laying around, like:

{{mobiledoc-editor mobiledoc=post.body key=post.id on-change=(action (mut post.body))}}

The above example would only rebuild the editor if key changes. It would safely ignore any of its own changes that come back down.

I implemented this pattern in a component that wraps mobiledoc-editor and it seems to work well.

ef4 avatar Mar 13 '16 08:03 ef4