onDocumentChange not called on block type change
See original GitHub issueHi @ianstormtaylor! I notice that if the block type changes (without any change to the text), the onDocumentChange
is not being fired. Is that expected?
Intuitively, I would expect that a change in block type would be considered a material change in document, to invoke this event.
Here is a JSFiddle demonstrating this - https://jsfiddle.net/urr1z99g/1/
Steps to Reproduce
- Open console.
- Click on ‘Toggle Heading’ to start a heading.
- At this point, I would expect the
onDocumentChange
andonChange
to be fired.
Thank you!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:26 (22 by maintainers)
Top Results From Across the Web
OnChangeBlockType Method of the IZoomViewerEvents ...
This method is implemented on the client-side. It is called by ABBYY FineReader Engine after the block type has been changed in Image...
Read more >Is there any onDocumentChange event? - Stack Overflow
Window with text "you've just changed DOM!" appears. I try to emulate "advanced" CSS selectors (e.g. +, >, [attr]) in IE6 using Javascript....
Read more >Eventing in Couchbase server to send an email once a ...
My motive is to make an HTTP call from evening function when a change is encountered in any document of the bucket. And...
Read more >OnDocumentChange event not firing - Inventor
So I started a new project with the wizard, pasted your code, changed my reference, and it would not work. Only the onsave...
Read more >rt - mozsearch - Searchfox
Name Description Size
amIAddonManagerStartup.rs jsval readStartupData () 9520
domstubs.rs 413
imgIEncoder.rs /// * imgIEncoder interface /// 7873
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s a workaround for now:
onDocumentChange
to avoid needless updates.onChange
method from yourEditor
instance directly, and pass in the transformed state.setState
after callingonChange
.Example:
This did not result in any additional renders of the Editor component in my testing.
@ianstormtaylor I did spend a fair amount of time looking into a proper fix, but this seems to go pretty deep into Slate’s update lifecycle, and it’ll take more time to figure out what’s happening when (and why), and ensuring that a fix doesn’t cause regressions. This workaround should at least take this issue out of blocker territory for most folks.
So I took a little look at this problem. Yea, it does look like it’s a problem w/ all transformations that are called via Javascript.
onBeforeChange
is called onEditor.componentWillReceiveProps
. ButonChange
is called as a proxy through theEVENT_HANDLERS
.So here are some options:
EVENT_HANDLER
for the transformationsonChange
when inapplyTransform
onChange
in thecomponentWillReceiveProps
@ianstormtaylor, what do you think? I’m still learning how everything is architected so I don’t have an opinion yet.