From 97bf34c45d6a72ac540b51edff5f783fc0cf57ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 25 Apr 2019 22:02:14 +0100 Subject: [PATCH] fix(ui): debounce grid updates so that they are batched --- ui/src/Components/Grid/AlertGrid/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/src/Components/Grid/AlertGrid/index.js b/ui/src/Components/Grid/AlertGrid/index.js index 5e5c350c6..28c1a62d4 100644 --- a/ui/src/Components/Grid/AlertGrid/index.js +++ b/ui/src/Components/Grid/AlertGrid/index.js @@ -80,11 +80,14 @@ const AlertGrid = observer( }); // used to call forcePack() which will repack all grid elements // (alert groups), this needs to be called if any group size changes - masonryRepack = action(() => { - if (this.masonryComponentReference.ref) { - this.masonryComponentReference.ref.forcePack(); - } - }); + masonryRepack = debounce( + action(() => { + if (this.masonryComponentReference.ref) { + this.masonryComponentReference.ref.forcePack(); + } + }), + 50 + ); // how many alert groups to render // FIXME reset on filter change