Skip to content

Commit

Permalink
Merge pull request #653 from FlowFuse/642-bgroup-payload-type
Browse files Browse the repository at this point in the history
Button-Group: Ensure type assignment for payload & update tests
  • Loading branch information
joepavitt authored Mar 12, 2024
2 parents 037870a + 4f4c628 commit 514bb1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cypress/tests/widgets/button-group.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Node-RED Dashboard 2.0 - Buttons', () => {
// Emitting Number
cy.clickAndWait(cy.get('button').contains('Left'))
cy.checkOutput('msg.topic', 'second-row')
cy.checkOutput('msg.payload', '0')
cy.checkOutput('msg.payload', 0)
})

it('can have a selection made via msg.payload', () => {
Expand Down
5 changes: 5 additions & 0 deletions nodes/widgets/ui_button_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ module.exports = function (RED) {
onChange: true
}

// loop over the options and ensure we've got the correct types for each option
config.options.forEach(option => {
option.value = RED.util.evaluateNodeProperty(option.value, option.valueType, node)
})

// inform the dashboard UI that we are adding this node
if (group) {
group.register(node, config, evts)
Expand Down
2 changes: 1 addition & 1 deletion ui/src/widgets/ui-button-group/UIButtonGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
this.selection = msg.payload
},
onChange (value) {
if (value) {
if (value !== null && typeof value !== 'undefined') {
// Tell Node-RED a new value has been selected
this.$socket.emit('widget-change', this.id, value)
}
Expand Down

0 comments on commit 514bb1e

Please sign in to comment.