From 71883f306c14853fde55fe5220543a7df696cb15 Mon Sep 17 00:00:00 2001 From: Aleksey Konstantinov Date: Mon, 19 Apr 2021 22:20:07 +0300 Subject: [PATCH] ULMS-1251 Fixed listener dropping for LockProvider --- package-lock.json | 2 +- package.json | 2 +- packages/drawing/package-lock.json | 2 +- packages/drawing/package.json | 2 +- packages/drawing/src/drawing.jsx | 2 ++ packages/drawing/src/lock-provider.js | 4 ++++ packages/drawing/src/lock-provider.test.js | 4 ++++ 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2501370..77b9a600 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@ulms/components", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d2af4bad..8c9143ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ulms/components", - "version": "1.4.0", + "version": "1.4.1", "description": "UI components library", "homepage": "https://github.com/netology-group/ulms-media-ui", "bugs": { diff --git a/packages/drawing/package-lock.json b/packages/drawing/package-lock.json index 2a7dd29f..eb1f19ea 100644 --- a/packages/drawing/package-lock.json +++ b/packages/drawing/package-lock.json @@ -1,6 +1,6 @@ { "name": "@ulms/ui-drawing", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/drawing/package.json b/packages/drawing/package.json index a79a6de1..7ad9c109 100644 --- a/packages/drawing/package.json +++ b/packages/drawing/package.json @@ -1,6 +1,6 @@ { "name": "@ulms/ui-drawing", - "version": "1.1.2", + "version": "1.1.3", "description": "", "keywords": [ "lerna" diff --git a/packages/drawing/src/drawing.jsx b/packages/drawing/src/drawing.jsx index ca38245b..e959664c 100644 --- a/packages/drawing/src/drawing.jsx +++ b/packages/drawing/src/drawing.jsx @@ -310,6 +310,8 @@ export class Drawing extends React.Component { } if (this.__lockProvider) { + this.__lockProvider.removeUpdateListener() + this.__lockProvider = null } diff --git a/packages/drawing/src/lock-provider.js b/packages/drawing/src/lock-provider.js index d93d0089..444b5863 100644 --- a/packages/drawing/src/lock-provider.js +++ b/packages/drawing/src/lock-provider.js @@ -26,6 +26,10 @@ export class LockProvider { this.listener = fn } + removeUpdateListener () { + this.listener = undefined + } + _updated (prev, next) { if (this.listener) { const changed = Boolean(!prev.length && next.length) diff --git a/packages/drawing/src/lock-provider.test.js b/packages/drawing/src/lock-provider.test.js index 556987b2..8f7a895a 100644 --- a/packages/drawing/src/lock-provider.test.js +++ b/packages/drawing/src/lock-provider.test.js @@ -19,5 +19,9 @@ describe('LockProvider', () => { provider.labels(['label_1', 'label_3']) expect(provider.isLocked('label_3')).toBe(true) + + provider.removeUpdateListener() + + expect(provider.listener).toBe(undefined) }) })