OctoPrint-Themeify icon indicating copy to clipboard operation
OctoPrint-Themeify copied to clipboard

"[Custom Tab] is not a child of the tab-list" in console log

Open OutsourcedGuru opened this issue 7 years ago • 4 comments

@jneilliii (In case he's interested since he wrote the Bed Level Visualizer plugin).

Failure to bind a tab icon to a custom tab

Themeify: Failed to add icon! #tab_plugin_bedlevelvisualizer_link is not a child of the tab-list!

Troubleshooting

Looks like there's a test in themeify.js, line 51 which fails for custom tabs.

        self.setupIcons = function() {
            self.tabIcons
                .tabs()
                .filter(tab => tab.domId() && tab.enabled())
                .map((tab, i) => {
                    const { domId, enabled, faIcon } = tab;
                    const icon = $(`<i>`, { class: faIcon() });
                    const elem$ = $(`${domId()} a`);
                    if (elem$ && elem$.closest('ul').attr('id') === 'tabs') {    # The part with "closest" fails
                        self.oldTabContent[domId()] = $(`${domId()} a`).html();
                        elem$.html(icon);
                    } else {
                        console.warn(
                            `Themeify: Failed to add icon! ${domId()} is not a child of the tab-list!`
                        );
                    }
                });
        };

Oddly enough, simply changing this to the following works as expected and without any apparent side-effects that I've been able to determine:

                    if (elem$) {

After removing the second part of that test

screen shot 2018-07-24 at 9 29 13 am

OutsourcedGuru avatar Jul 24 '18 16:07 OutsourcedGuru

Thanks for the detailed report, seems to be related to #32. I will look into it, as well as the other open issues very soon.

Birkbjo avatar Jul 24 '18 16:07 Birkbjo

This seems to work for me. Did you include the "#" in the selector? Ie. "#tab_plugin_bedlevelvisualizer_link".

The reason for that test is to not conflict with other element ids. Might be overkill, but I think it's reasonable.

Birkbjo avatar Jul 25 '18 02:07 Birkbjo

Yeah, I've got the pound sign. (I've currently patched my packed_plugins.js to remove the second part of that test and it seems to be happy... until the 1.3.9 update of course.)

Safari 11.1.2; OSX 10.13.6

OutsourcedGuru avatar Jul 25 '18 15:07 OutsourcedGuru

The problem is, when many plugins are there, Octoprint joins the ones that don't fit into the ROW -> on the right side in a drop-down list and your plugin can't find them in the main DOM element. At that time, they are text only and are too wide to fit. Your plugin gives them icons, so then they are not too wide anymore and OctoPrint lists them normally, beacuse the icons are not as wide as the plain text. You could incrementally change each text with an icon and wait for OctoPrint to update the list with more plugins that now after giving them icons actually fit on the list and not on the dropdown on the right.

dayaan82 avatar May 03 '19 23:05 dayaan82