From 4154bd3886a8c09e19a4c8c68bdc8ff08d58a8db Mon Sep 17 00:00:00 2001 From: Jared Stoffan Date: Tue, 27 Aug 2019 19:37:57 -0700 Subject: [PATCH] fix(csv): Avoid mutation in CSV viewer when sorting for column count (#1057) --- src/lib/viewers/text/BoxCSV.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/viewers/text/BoxCSV.js b/src/lib/viewers/text/BoxCSV.js index dd82f7c1b..010935d67 100644 --- a/src/lib/viewers/text/BoxCSV.js +++ b/src/lib/viewers/text/BoxCSV.js @@ -72,8 +72,9 @@ class BoxCSV { * @private */ renderCSV() { - const rowCount = this.data.length; - const rowSample = this.data.sort((a, b) => b.length - a.length)[0]; // Find the row with the most columns + const rowData = [...this.data]; + const rowCount = rowData.length; + const rowSample = rowData.sort((a, b) => b.length - a.length)[0]; // Find the row with the most columns const columnCount = rowSample.length; const maxWidth = this.csvEl.clientWidth;