# Error when trying to add a custom sidebar tab

**URL:** https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267
**Category:** Core Development
**Tags:** possible-bug
**Created:** [12 June 2026 13:16 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267 "2026-06-12T13:16:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [12 June 2026 13:16 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/1 "2026-06-12T13:16:16Z")

</div>

Moved from the NR v5 thread as I think this might be a bug from before then?

* * *

Ah, another sidebar issue?

UIBUILDER has the `uib-sidebar` node that creates a custom sidebar - in NR5, unless I'm missing something, there doesn't appear to be a way to get to that sidebar any more. It was working fine before and, I think, was working in the beta.

* * *

Hmm, actually, it might be a bug in the uib-sidebar node.

* * *

So this actually appears to be a bug in core - I think.

```javascript
function w(a) {
  return N.primary.tabs.contains(a)
}

```

Sorry, I can't find this in the actual node-red code, that is how it appears in the browser when viewing the Editor page.

In my `uib-sidebar` node, I watch for an instance of the node being added and, for the first instance only, try to add the sidebar tab. But first, I test for whether it already exists using:

```javascript
    RED.events.on('nodes:add', function(node) {
        if (node.type === moduleName) {
            // console.log(`🌐📊[uib-sidebar] Node added: ${node.id}`, node.html)
            window['uibSidebarNodeCount']++
            console.info(`🌐📊[uib-sidebar] Node count: ${window['uibSidebarNodeCount']}`)
            // When the first uib-sidebar node is added ...
            if (window['uibSidebarNodeCount'] === 1) {
                log('🌐📊[uib-sidebar] FIRST uib-sidebar added - ADDING SIDEBAR')
                let uibSb = false
                try {
                    uibSb = RED.sidebar.containsTab('uibuilder-sidebar-ui')
                } catch (e) {
                    // Ignore - this just means the sidebar tab doesn't exist yet
                    console.error('🌐📊[uib-sidebar] Error checking for existing sidebar tab:', e)
                }
                // Add the sidebar tab
                if (!uibSb) {
                    RED.sidebar.addTab({
                        id: 'uibuilder-sidebar-ui',
                        label: 'uib UI',
                        name: 'UIBUILDER Sidebar UI',
                        content: sbMasterEl,
                        // toolbar: uiComponents.footer,
                        enableOnEdit: true,
                        iconClass: 'fa fa-globe uib-blue',
                    })
                }
            }
   ...

```

The line:

```js
uibSb = RED.sidebar.containsTab('uibuilder-sidebar-ui')

```

Produces the error:

```auto
VM4018:127 🌐📊[uib-sidebar] Error checking for existing sidebar tab: TypeError: Cannot read properties of undefined (reading 'contains')
    at Object.w [as containsTab] (red.min.js?v=358a4182b458:97:106251)
    at <anonymous>:124:41
    at Object.k [as emit] (red.min.js?v=358a4182b458:16:23144)
    at h (red.min.js?v=358a4182b458:18:16973)
    at Object.nt [as import] (red.min.js?v=358a4182b458:18:44991)
    at Object.success (red.min.js?v=358a4182b458:16:3526)
    at c (vendor.js?v=358a4182b458:2:25304)
    at Object.fireWith [as resolveWith] (vendor.js?v=358a4182b458:2:26053)
    at l (vendor.js?v=358a4182b458:2:77782)
    at XMLHttpRequest.<anonymous> (vendor.js?v=358a4182b458:2:80265)

```

When tracing the problem, I find the error is generated in that initial code I posted. It turns out that the `tabs` property is undefined.

I think this is probably a bug in that code and it probably should be something like:

```js
function w(a) {
    return N.primary?.tabs?.contains(a) ?? false
}

```

---

<div class="post-metadata">

### Author: ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)
#### Post date: [12 June 2026 15:04 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/2 "2026-06-12T15:04:43Z")

</div>

> <https://github.com/node-red/node-red/pull/5327>
>
> This is part of the Node-RED modernisation work - https://github.com/node-red/no…de-red/issues/5317
> 
> It updates the sidebar UX to use a column of buttons alongside the sidebar to switch between sidebars.
> 
> \<img width="1624" height="616" alt="image" src="https://github.com/user-attachments/assets/b5f1f4a2-1873-43f9-b981-122170d434eb" /\>
> 
> This makes the sidebars more discoverable as they aren't hidden in a dropdown list.
> 
> There are various UX changes as a result of this:
> 
> - The expand/shrink control is no longer used. The sidebar can be hidden by clicking on the active tab button to the side - it acts as a toggle.
> \<img width="40" alt="image" src="https://github.com/user-attachments/assets/fc09b240-257b-4502-96b3-0c6ca685f3ad" /\>
> - The tab buttons can still be dragged to change their order
> - \*\*The tab buttons can be dragged between the right-hand and left-hand sidebars\*\* - this allows the user to pick where each sidebar is shown.
> 
> 
> \### To Do
> 
> Not everything works yet.
> 
> - ~The node edit tray position is broken (again)~
> - Not all core sidebar panels work well on the LH side - they have been designed to be on the RH side. Need to work through individual issues for them.
> - ~The new 'Palette' sidebar has a temporary icon~ - reusing subflow icon for initial iteration
> - ~The editor doesn't remember any layout changes or reordering the user makes. ~ done
> - Need to handle if there isn't enough vertical space for all of the sidebar buttons - likely to defer this

Missing `sidebar.tabs` instantiation in `setupSidebar`.

I'm not sure what's supposed to replace that 🤔

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [12 June 2026 15:17 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/3 "2026-06-12T15:17:10Z")

</div>

Hmm, thanks. But the `RED.sidebar.containsTab` function is still there so this is definitely a bug one way or another right? Either that function should be removed from the code and documentation or the tabs property should be fixed or the containsTab function should be amended as shown.

As it happens, I don't really need that function I don't think since I am manually tracking for node instances and will only add it for the first instance anyway. So I have a work around.

---

<div class="post-metadata">

### Author: ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)
#### Post date: [12 June 2026 15:21 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/4 "2026-06-12T15:21:22Z")

</div>

Looking at the new code, I would say the fix is:

```js
function containsTab(id) {
  return !!knownTabs[id];
}

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [12 June 2026 15:29 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/5 "2026-06-12T15:29:02Z")

</div>

`RED.sidebar.containsTab()` isn't actually used anywhere in the editor code - which is how this has slipped through.

Lets get an issue raised and we'll fix it up.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [12 June 2026 15:39 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/6 "2026-06-12T15:39:36Z")

</div>

Done:

> <https://github.com/node-red/node-red/issues/5804>
>
> \### Current Behavior
> 
> As per the disussion in https://discourse.nodered.org/t/er…ror-when-trying-to-add-a-custom-sidebar-tab/101267
> 
> This function is now failing.
> 
> \### Expected Behavior
> 
> Should not fail
> 
> \### Steps To Reproduce
> 
> Use RED.sidebar.containsTab in a node's Editor code.
> 
> \### Example flow
> 
> N/A
> 
> 
> \### Environment
> 
> \- Node-RED version: 5

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 August 2026 15:40 UTC](https://discourse.nodered.org/t/error-when-trying-to-add-a-custom-sidebar-tab/101267/7 "2026-08-11T15:40:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
