diff --git a/front/src/routes/scene/edit-scene/actions/BlinkLightParams.jsx b/front/src/routes/scene/edit-scene/actions/BlinkLightParams.jsx index 2de853bba4..d0190ad4b0 100644 --- a/front/src/routes/scene/edit-scene/actions/BlinkLightParams.jsx +++ b/front/src/routes/scene/edit-scene/actions/BlinkLightParams.jsx @@ -14,10 +14,12 @@ class BlinkLight extends Component { device_feature_category: 'switch', device_feature_type: 'binary' }); - const deviceOptions = [...lightDevices, ...switchDevices].map(device => ({ - value: device.selector, - label: device.name - })); + const deviceOptions = [...lightDevices, ...switchDevices] + .map(device => ({ + value: device.selector, + label: device.name + })) + .sort((d1, d2) => d1.label.localeCompare(d2.label)); await this.setState({ deviceOptions }); this.refreshSelectedOptions(this.props); return deviceOptions; @@ -43,13 +45,14 @@ class BlinkLight extends Component { refreshSelectedOptions = nextProps => { const selectedOptions = []; if (nextProps.action.devices && this.state.deviceOptions) { - nextProps.action.devices.forEach(light => { - const deviceOption = this.state.deviceOptions.find(deviceOption => deviceOption.value === light); + nextProps.action.devices.forEach(device => { + const deviceOption = this.state.deviceOptions.find(deviceOption => deviceOption.value === device); if (deviceOption) { selectedOptions.push(deviceOption); } }); } + selectedOptions.sort((d1, d2) => d1.label.localeCompare(d2.label)); this.setState({ selectedOptions }); }; constructor(props) { diff --git a/server/test/lib/scene/actions/scene.action.blinkDevices.test.js b/server/test/lib/scene/actions/scene.action.blinkDevices.test.js index 659c998e8b..f3c9998adc 100644 --- a/server/test/lib/scene/actions/scene.action.blinkDevices.test.js +++ b/server/test/lib/scene/actions/scene.action.blinkDevices.test.js @@ -8,7 +8,7 @@ const StateManager = require('../../../../lib/state'); const event = new EventEmitter(); -describe('scene.blink-devices', () => { +describe('scene.blink-lights', () => { let clock; beforeEach(() => {