Fix: Defer re-decorating note when changing search #2073
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #1941
See #1982
When we rebuilt the search to return instant results and removed the debounce
on the search filter we exposed an issue with note rendering performance that
ironically made the new instant search slower than the old one in certain
circumstances, namely when a note in the search results takes a very long time
to render.
The leading reason for the performance issue is that
draft-js
was applyinga new decorator to its note on every change to the search field. With the
search field updating instantly that left no time for the decorators to redraw
(and they were very inefficient to make it worse).
In this patch we're delaying the re-decoration until the search field settles.
This doesn't eliminate the problem but it should bring it roughly on par with
the behavior from before the search updates.
Further we have eliminated the
Scratch that - there's a slight API change that would require more code to change. Since there's no need to create a composite decorator when the searchMultiDecorator
dependency since that functionality is provided bydraft-js
itself
query doesn't contain any text terms we can futher skip it and only decorate
with the checkbox decorator.
These changes should make searching tolerant to slow notes and should
additionally cut the time it takes to decorate notes approximately in half.
Changes
Notes
draft-js
. Further work to improve this probably needs to involve replacing draft-js