block-components
block-components copied to clipboard
ContentPicker search for a custom post type post crashes block
Describe the bug
When searching for a custom post type post in ContentPicker javscript error triggers and block that uses ContentPicker crashes. Expecting search results to show without crashing the block.
Steps to Reproduce
- create a custom post type
- add some posts of that post type
- create a block that uses ContentPicker and set contentTypes to be custom post type created in step 1
- go to editor and add block created in step 3
- search for posts
- every other or third time block will crash
Screenshots, screen recording, code snippet
In console this error gets triggered:
react-dom.min.js?ver=18.2.0:10 TypeError: Cannot set properties of undefined (setting 'results')
at index.js:70:2558
Where index.js
is node_modules/@10up/block-components/dist/index.js
Timing seems to be an issue, when I type a letter then wait for results to load, then type another letter and wait for results to load, and so on, the error never happens. Only if I type a couple of letters then it will crash. It's not consistently crashing, maybe every other or third time. Seems that canceled requests cause this issue, when several letters are typed, previous letters (word so far) search requests get canceled.
Environment information
No response
WordPress information
Versions above 6.0, though I think I've seen this on versions below 6.0 too.
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Hey @Spoygg 👋
Are you able to provide a screenshot / the value of the network request that happens when you type in the content search?
@fabiankaegy sure. Here's gif of all request made while I'm typing "unity". Not sure if that's an issue but the last one is sent twice (containing "unity" as search string).
I can try debugging with uncompressed library to see what's actually going on.
Also it happens with ContentPicker being in InspectorControls or in the block body.
Here I was looking for "cult". It seems to try to store results for "cu" although that request was canceled already. First time it hits that line it's not an issue, but second time it breaks. Not very clear what's happening since code is compressed. I can take a look later in the week.
Hi any updates on this issue?
Same thing happens on me as Spoygg
This issue should be closed with version 1.19.0 of the block components. Thanks for your patience