Skip to content

Button commands trigger multiple times when custom widget is present #1486

@CKraw

Description

@CKraw

I noticed something like a faulty behaviour of click events from widget buttons. Depending on whether a custom widget is loaded alongside any other widget that (assumingly) features the same type of buttons, the connected commands get triggered multiple times.

I am using the newest version of Mycodo (8.16.2). The issue persists across different web browsers and is consistently reproducible.

To prepare an easy to recreate test scenario, I took the following steps:

  1. Define an output for a peristaltic pump Peristaltic Pump: Atlas Scientific [I2C] (specific config settings don't really matter)
  2. Put a regular, native widget Output Control (Channel) on a new dashboard and insert the output (from 1.), so we have some buttons to work with (any other widget config settings don't matter)
  3. Add another widget of the same type (this may even just be left empty, inserting any output is not necessary)
  4. Just click some buttons (the upcoming screenshots are from clicking the button "On")

For now, this shows the correct behaviour:

Now let's bring in a custom widget. To clarify the origin of the problem, which should not be caused by any bad coding in my custom widget, I just copied the code of the original widget from Mycodo's Github and pasted it into an empty python file (named widget_outputtest.py). The only code adjustments I made was renaming the values of widget_name_unique and widget_name, so they won't clash with the existing widget:

WIDGET_INFORMATION = {
    'widget_name_unique': 'widget_out',
    'widget_name': 'Out Control (Channel)',

After importing this test custom widget to Mycodo and adding it to the dashboard (by replacing the original widget from step 3.), the issue of the button command being triggered twice occurs as indicated by the displayed toasts:

Btw, when inserting some output into the custom widget, using the buttons from therein will have the same faulty effect:

It seems like the routing of commands within widgets is getting confused whenever a custom widget is present alongside. Maybe there is anything wrong with the collection of generated click event handlers? Like any of them would fire, even though their actual parent button was not clicked...

@kizniche I hope the given info is sufficient to draw your attention to this issue. I would much appreciate if you could provide a fix in an upcoming release. Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions