decorateWidget no longer working

I was using the following code in the </head> area of my customized theme. It was working fine, my custom navbar appeared. I tried to add another element to the custom navbar, and on preview nothing appeared. I tried to change the code back and it still didn’t work. I did some searching and can’t find any information on this, and also can’t find any errors in the console or on the page besides Failed to load resource: the server responded with a status of 404 () for https://mysite.com/javascripts/3804c7ea6ae9ec374a92e92086024dcdac103c0d.js.

I have some custom CSS as well to hide other elements I don’t want, but looking at the source, I don’t think that’s what’s going on since the elements don’t even seem to be created.

And when I replace this code with the following, I don’t get any console output besides that 404:

<script>console.log("working");</script>

Any ideas on what is wrong or what I could look at to try to fix it?

api.decorateWidget('home-logo:after', helper => {
    return helper.h('div', [
        helper.h('div#banner_container', [
            helper.h('a', {
                href: 'https://mysite.com'
            }, helper.h('img#header_word_logo', {
                    src: 'https://mysite.com/uploads/default/original/1X/imgcode.png'
                })
            )
        ]),
        helper.h('ul#header_menu', [
            helper.h('li', [
                helper.h('a', {
                    href:'https://www.mysite.com/1',
                    title: 'Section1'
                }, 'Section1'),
            ]),
            helper.h('li', [
                helper.h('a', {
                    href:'https://www.mysite.com/2',
                    title: 'Section2'
                }, 'Section2'),
            ]),
            helper.h('li', [
                helper.h('a.current_page_item', {
                    href:'https://www.mysite.com/3',
                    title: 'Section3'
                }, 'Section3'),
            ]),
            helper.h('li', [
                helper.h('a', {
                    href:'https://www.mysite.com/4',
                    title: 'Section4'
                }, 'Section4'),
            ]),
            helper.h('li', [
                helper.h('a', {
                    href:'https://www.mysite.com/5',
                    title: 'Section5'
                }, 'Section5'),
            ]),
        ]),
    ]);
});
</script>

Thank you for any and all help in advance!

4 Likes

Hey Ben, this has been fixed with https://github.com/discourse/discourse/commit/99d1ded3b3a2767617bbee9824e93eb57f135864. Could you please update your site to latest and try again?

After the update, you may need to edit your custom JavaScript (adding/removing a trailing space will do) to trigger a cache rebuild to see the effects.

8 Likes

That was the issue, thank you so much @xrav3nz!

1 Like

This topic was automatically closed after 2 days. New replies are no longer allowed.