onPageChange handler raised an error

AI-generated summary

A user reported a TypeError: Cannot read properties of undefined (reading 'name') error in the browser console when using the custom-category-boxes theme component, triggered by the onPageChange handler. The issue occurred on some pages but not others, and was not resolved by renaming categories. Another user confirmed the same error in safe mode, unrelated to the theme, and provided a URL where it occurred. A developer identified the issue and fixed it in a pull request 23. The original reporter confirmed the fix resolved the problem 7 and 8.

Hi all - I installed the custom-category-boxes theme component, and on some (but not all) of my pages, I receive a warning banner at the top and see the following in my browser console. It appears that this is because the c variable ends up being null–why that is, I did not investigate further.

client-error-handler.js:125 [THEME 2 'Custom Category Boxes'] 
TypeError: Cannot read properties of undefined (reading 'name')
    at category-banner.js:31:24
    at plugin-api.js:127:26
    at AppEvents.<anonymous> (plugin-api.js:736:50)
    at m (index.js:200:1)
    at AppEvents.trigger (evented.js:27:1)
    at page-tracker.js:41:17
    at invoke (backburner.js.js:282:1)
    at h.flush (backburner.js.js:197:1)
    at p.flush (backburner.js.js:358:1)
    at B._end (backburner.js.js:798:1)
    at B.end (backburner.js.js:589:1)
    at B._runExpiredTimers (backburner.js.js:905:1)
reportToConsole	@	client-error-handler.js:125

At first I thought this may be due to the category names having spaces in them, but even renaming one category to have no spaces continues to throw this error.

Happy to provide more information if wanted/needed. The forum in question is https://forums.rockylinux.org

2 Likes

Can you share pages where it happens?

I also noticed an Uncaught TypeError: Cannot read properties of undefined (reading 'name'). But it isn’t related to custom category boxes; it even happens in safe mode.

When I open https://meta.discourse.org/u/chapoi/invited/redeemed?safe_mode=no_themes%2Cno_plugins in a new window or tab, I get this:


It does not happen when I remove ‘redeemed’ from the URL, and I was not able to reproduce it using a staff user.

I got it at https://forums.rockylinux.org/c/techhelp/6

1 Like

Thanks for report, that should fix it:

https://github.com/discourse/discourse-custom-category-boxes-component/pull/23

4 Likes

Fantastic! thank you so much. I’ll get it updated on our instance immediately :slight_smile:

1 Like

Confirmed – works perfectly. Thank you for the prompt fix :slight_smile:

1 Like