From 4a46d983db397ea2528318c37d604cda93085a56 Mon Sep 17 00:00:00 2001 From: Charles Lee Date: Fri, 16 Feb 2024 15:20:47 +1100 Subject: [PATCH] Add check for stickyTableHeadings.current.length in resizeTableHeadings so our code does not error when the ref is not initialised --- polaris-react/src/components/IndexTable/IndexTable.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/polaris-react/src/components/IndexTable/IndexTable.tsx b/polaris-react/src/components/IndexTable/IndexTable.tsx index 84b280dcd3f..95bd7609ebb 100644 --- a/polaris-react/src/components/IndexTable/IndexTable.tsx +++ b/polaris-react/src/components/IndexTable/IndexTable.tsx @@ -304,7 +304,11 @@ function IndexTableBase({ } // update left offset for first column - if (selectable && tableHeadings.current.length > 1) { + if ( + selectable && + tableHeadings.current.length > 1 && + stickyTableHeadings.current.length > 1 + ) { tableHeadings.current[1].style.left = `${tableHeadingRects.current[0].offsetWidth}px`; stickyTableHeadings.current[1].style.left = `${tableHeadingRects.current[0].offsetWidth}px`; }