Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown widget loses it’s entries when switching tabs #1117

Closed
natcl opened this issue Jul 21, 2024 · 6 comments · Fixed by #1123
Closed

Dropdown widget loses it’s entries when switching tabs #1117

natcl opened this issue Jul 21, 2024 · 6 comments · Fixed by #1123
Assignees
Labels
bug Something isn't working size:S - 2 Sizing estimation point

Comments

@natcl
Copy link

natcl commented Jul 21, 2024

Current Behavior

I’m setting the options of a dropdown widget at startup using msg.options which works fine. If I switch to another tab and switch back the entries are gone, they don’t seem to persist.

Expected Behavior

I would expect the options to persist between tab changes.

Steps To Reproduce

Inject options via msg.options at startup on a widget on tab A. Switch to tab B and come back to tab A, options are now gone.

Environment

  • Dashboard version: 1.13.0
  • Node-RED version: 4.0.2
  • Node.js version: 20.15.1
  • npm version:
  • Platform/OS: Alpine 3.20
  • Browser: Safari

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

@natcl natcl added bug Something isn't working needs-triage Needs looking at to decide what to do labels Jul 21, 2024
@natcl
Copy link
Author

natcl commented Jul 21, 2024

@joepavitt
Copy link
Collaborator

Can reproduce. Oddly, the dynamic data is correctly stored server-side, and persists - you can check this by looking at our behind-the-scenes debug view at your-instance:1880/dashboard/_debug

So this suggests that the problem is that the widget-load event isn't correctly firing on a page-switch such that we load the latest state with updated options. Even as a backup though, we should have this data stored in the VueX store on the client-side, so it should have two backups... but neither of which are functioning correctly.

@gayanSandamal can you investigate the details when you have a chance please?

@joepavitt joepavitt moved this to In Progress in Dashboard Backlog Jul 23, 2024
@joepavitt joepavitt added size:S - 2 Sizing estimation point and removed needs-triage Needs looking at to decide what to do labels Jul 23, 2024
@gayanSandamal
Copy link
Contributor

@joepavitt I'll investigate this further

@arturv2000
Copy link
Contributor

Just my 2cents, this is an issue similar to what happens in other widgets, the onLoad event may not handle / update the msg.ui_update properties, and the event onDynamicProperties not being "triggered" independently when the widget is loaded.

a possible fix is:

onLoad (msg) {
    // update vuex store to reflect server-state
    this.$store.commit('data/bind', {
        widgetId: this.id,
        msg
    })
    this.onDynamicProperties(msg)  // Get the `ui_update` properties that may exist for this widget at load time, until is properly handled in `data_tracker.mjs`, needs to be called before `this.select`
    this.select(this.messages[this.id]?.payload)
},

To make sure we load the ui_update values correctly on widget-load event, this only works well if the last message sent to the widget has all the ui_update values. This should be handled better in data-tracjer.mjs (I think) in order to fetch the stored properties for ui_update, don't know if data-tracker is the best place for this action or if it better to be on widget.js.

@colinl
Copy link
Contributor

colinl commented Jul 24, 2024

Should not the ui_update changes be saved in the statestore so that they are are sent up when the widget connects after a page change?

@joepavitt
Copy link
Collaborator

Should not the ui_update changes be saved in the statestore so that they are are sent up when the widget connects after a page change?

They are saved, but my downfall right now is not including the statestore content in the onLoad function call, which I definitely need to do as @arturv2000 mentioned.

@gayanSandamal this has links to a few other discussions, etc. I've been involved in over the past few weeks, so I'll likely take this one back off your hands as it could be quite the beast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:S - 2 Sizing estimation point
Projects
Status: Done
5 participants