-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Query block: Fix dirtying post on load #27323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Size Change: +7 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
@@ -129,8 +129,12 @@ export default function QueryInspectorControls( { | |||
|
|||
const [ querySearch, setQuerySearch ] = useState( query.search ); | |||
const onChangeDebounced = useCallback( | |||
debounce( () => setQuery( { search: querySearch } ), 250 ), | |||
[ querySearch ] | |||
debounce( () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debounce
makes me always think that there is an underlying problem that can't be easily solved and it makes the issue invisible. Do you know why is it called in useEffect
in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it exist here to prevent too many requests to the server when typing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it exist here to prevent too many requests to the server when typing?
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this in, it makes sense to include this check.
I'm wondering if in the future the local state could be removed completely in this component in favor of setQuery
call. It would require updating the part that triggers network requests to use debouncing instead, but it would benefit the case when changing other properties quickly as well.
6f36148
to
106ccdb
Compare
106ccdb
to
143aea1
Compare
Description
Fixes: #26838
There was a bug that when loading a post with a
Query
block would trigger an initial update to its attributes without needing it. This PR fixes it.