From 5f0ee8770c3b3acfb45fd8701d7e0b98f4df2e4a Mon Sep 17 00:00:00 2001 From: atrovato <1839717+atrovato@users.noreply.github.com> Date: Sat, 12 Dec 2020 09:22:31 +0100 Subject: [PATCH] Fix color picker removeEventListener --- .../device-in-room/device-features/ColorDeviceFeature.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/front/src/components/boxs/device-in-room/device-features/ColorDeviceFeature.jsx b/front/src/components/boxs/device-in-room/device-features/ColorDeviceFeature.jsx index 43a0d15137..2f27a4dedd 100644 --- a/front/src/components/boxs/device-in-room/device-features/ColorDeviceFeature.jsx +++ b/front/src/components/boxs/device-in-room/device-features/ColorDeviceFeature.jsx @@ -32,7 +32,7 @@ class ColorDeviceType extends Component { setColorPickerState = (open, fromEvent) => { if (!open) { - document.removeEventListener('click', this.blur); + document.removeEventListener('click', this.blur, true); } this.setState({ open, fromEvent }, () => { @@ -65,7 +65,6 @@ class ColorDeviceType extends Component { componentDidMount() { const deviceLastValue = this.props.deviceFeature.last_value; const color = deviceLastValue === null ? undefined : `#${intToHex(deviceLastValue)}`; - console.log(deviceLastValue, color); this.colorPicker = new iro.ColorPicker(this.colorPickerRef.current, { width: 150, @@ -80,6 +79,10 @@ class ColorDeviceType extends Component { this.colorPicker.on('input:end', color => this.updateValue(color)); } + componentWillUnmount() { + document.removeEventListener('click', this.blur, true); + } + render({ device, deviceFeature }, { open }) { const deviceLastValue = deviceFeature.last_value; const color = deviceLastValue === null ? undefined : `#${intToHex(deviceLastValue)}`;