# Unintentional exiting of a tab

**URL:** <https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [11 July 2024 15:53 UTC](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428 "2024-07-11T15:53:24Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 July 2024 14:26 UTC](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428/21 "2024-07-14T14:26:13Z")

</div>

The ui-control node will emit an event when the tab is changed... you could use that to trigger a notification asking if they want to save. Though this is only emitted after the tab has been changed - but as already pointed out the changed data is most likely already back on the server - so you could then optionally write it out.

---

<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:** [14 July 2024 14:53 UTC](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428/22 "2024-07-14T14:53:17Z")

</div>

> [@gNeandr](#):
>
> The core of the core here is that a table is read from a JSON file with a flow/tab. Then the editing of the table takes place.

I think at this point, you need to share some code because we aren't seeing the full picture. Best to share a simplified flow that gives some example data and shows the table. Then we can test out exactly what happens.

---

<div class="post-metadata">

**Author:** ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)\
**Post date:** [14 July 2024 15:34 UTC](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428/23 "2024-07-14T15:34:21Z")

</div>

> [@TotallyInformation](#):
>
> I think at this point, you need to share some code because we aren't seeing the full picture. Best to share a simplified flow that gives some example data and shows the table. Then we can test out exactly what happens.

I am trying to build a simplified flow.

But a very simple solution would be to set a "dirty" bit that can be used for an action before leaving a tab. Whatever has happened on the TAB.  
In my case it would be a dialogue asking the user if he wants to save the data of the table to a file first ... or ignore it and leave the TAB without further action ... and discard the changed data

---

<div class="post-metadata">

**Author:** ![gNeandr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gneandr/32/73947_2.png) [@gNeandr](https://discourse.nodered.org/u/gNeandr)\
**Post date:** [14 July 2024 23:59 UTC](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428/24 "2024-07-14T23:59:40Z")

</div>

Here is a possible solution to prevent the user from switching to another TAB.  
In this proposal, the 'disabled' property of the toolbar button is switched. If it has the status 'disabled = true', the button is black and inactive.  
This can be extended further.

```auto
[{"id":"2a6b6ab3734ed4da","type":"inject","z":"b2e0efbc7b7d96a6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"tbchange","payload":"","payloadType":"date","x":270,"y":1480,"wires":[["5ae5eb46e1058642"]]},{"id":"5ae5eb46e1058642","type":"ui_template","z":"b2e0efbc7b7d96a6","group":"d89bc0bf341145b9","name":"pbToolbar","order":8,"width":4,"height":1,"format":"<!-- Pseudo Button -- work with toolbar icon -->\n\n<style>\n .jobcall {\n margin-top: 10px !important;\n width: 100% !important;\n display: flex;\n align-items: center;\n flex-direction: column;\n }\n</style>\n\n<div class=\"jobcall\">\n <p ng-click=\"send({payload:jobcall('XYZ')})\" >\n <i id=\"isave\" class=\"fa fa-bars fa-lg\" style=\"color:black; cursor:pointer\" ></i>\n </p>\n</div>\n\n<script>\n\n var d; // toolbar button status\n\n (function(scope) {\n\n scope.jobcall = function(x) {\n\n console.log(\"toolbarbutton :\", d) \n msg = {};\n msg.payload = x;\n msg.toolbarbutton = d;\n return msg;\n }\n \n scope.$watch('msg', function(msg) {\n if (msg) {\n if (msg.topic === 'tbchange'){\n d = $(\".md-icon-button\")[0].disabled;\n console.log(`toolbar icon watch ${d} ${msg.topic} `);\n \n $(\".md-icon-button\")[0].disabled = (d === true) ? false : true;\n }\n }\n }); \n })(scope);\n</script> ","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","className":"","x":460,"y":1480,"wires":[["7c8b4f51359b43cc"]]},{"id":"7c8b4f51359b43cc","type":"debug","z":"b2e0efbc7b7d96a6","name":"tb status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":1480,"wires":[]},{"id":"d89bc0bf341145b9","type":"ui_group","name":"Plan bearbeiten","tab":"dd8e409b7c560497","order":2,"disp":false,"width":"10","collapse":false,"className":""},{"id":"dd8e409b7c560497","type":"ui_tab","name":"Pläne erstellen","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

```

![tbstatus](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/97d41f69c3513f6ab6d02e3ed3db45824c7c5864.png)  
Works with Dashboard 1

_Edit_  
_Minor functional correction of the flow:_  
_-- enable/disable of the 'toolbar tab button' with 'inject' node_  
_-- pseudo button just will list the current status of the 'toolbar tab button' to nr-debug and console_

---

<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:** [29 July 2024 00:00 UTC](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428/25 "2024-07-29T00:00:13Z")

</div>

Closed on 29 July 2024 00:00 UTC

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

[Previous page](https://discourse.nodered.org/t/unintentional-exiting-of-a-tab/89428.md?page=1)
