Avoid calling redux actions constantly when moving the mouse or scrolling#44325
Avoid calling redux actions constantly when moving the mouse or scrolling#44325youknowriad merged 4 commits intotrunkfrom
Conversation
|
Size Change: +73 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
| * | ||
| * @return {Record<string,boolean>} Block visibility. | ||
| */ | ||
| export function blockVisibility( state = {}, action ) { |
There was a problem hiding this comment.
Moving blockVisibility state of the "blocks" state means any change to "blockVisibility" won't have an impact on the undo/redo behavior.
before this a call to SET_BLOCK_VISIBILITY would force an undo state even if we were typing in the middle of a word.
draganescu
left a comment
There was a problem hiding this comment.
I have tested this by making some commonly large posts and seeing if there is any flicker or delay in how blocks show up. I did not notice a difference vs trunk for scrolling but I did notice a great difference in how intentful the inserter showing up feels.
Although the numbers seem the same in this PR the delay in which the inserter shows up is actually real, I found this very refreshing getting rid of the flickering inserter on scroll.
The code LGTM ![]()
What?
I've noticed that when you scroll the page or when you move the mouse on the editor canvas, there are redux actions that are constantly called, causing potential re-renders and this might slow the editor and remove the feeling of responsiveness. This PR makes sure these actions are delayed/debounced accordingly.
Why?
To improve the responsive of the editor when moving around.
How?
setBlockVisibilityaction which is responsible of the sync/async behavior of the data module is delayed and batched.showInsertionPointcall entirely to avoid re-rendering, that way when you move the mouse across blocks, the insertion point action is not triggered at all unless you stay more than 500ms between the blocks.I'm not sure we have performance metrics that show the impact here but I'm convinced this will largely improve the responsiveness when moving the mouse on large posts.
Testing Instructions
1- Test the in-between inserter
2- Try scrolling and moving the mouse around especially with large posts.