From 1b43b94072d3f69f095b3ca89a9aa9cafe6c8f9e Mon Sep 17 00:00:00 2001 From: Mangala SSS Khalsa Date: Thu, 18 Jun 2020 22:45:19 -0700 Subject: [PATCH] _StoreMixin: clamp rows.max to a minimum of 0 If the rows of a grid are removed from bottom to top then each row removal will decrement rows.max, including the final row removal which will set rows.max to -1. This breaks the logic in _StoreMixin's 'add, update' event handler preventing insertion of new rows when items are added to the store. Fixes #1305 --- _StoreMixin.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_StoreMixin.js b/_StoreMixin.js index 1629e51ab..9ee4b1609 100644 --- a/_StoreMixin.js +++ b/_StoreMixin.js @@ -460,6 +460,12 @@ define([ rows.max--; } + // max should never be less than zero; if it is the logic in the 'add, update' handler + // below will prevent insertion of rows (https://github.com/SitePen/dgrid/issues/1305) + if (rows.max < 0) { + rows.max = 0; + } + row = rows[from]; // check to make the sure the node is still there before we try to remove it