From 2d484c57524e3c50734fc3447d05f0ed51bef058 Mon Sep 17 00:00:00 2001 From: sanchit-agarwal Date: Thu, 4 Apr 2024 21:21:36 +0530 Subject: [PATCH] check rangeCount before getRangeAt --- packages/core/src/modules/cell.ts | 1 + packages/core/src/modules/inline-string.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/core/src/modules/cell.ts b/packages/core/src/modules/cell.ts index 216b83a3..673f0e4d 100644 --- a/packages/core/src/modules/cell.ts +++ b/packages/core/src/modules/cell.ts @@ -1224,6 +1224,7 @@ export function isAllSelectedCellsInStatus( if (!_.isEmpty(ctx.luckysheetCellUpdate)) { const w = window.getSelection(); if (!w) return false; + if (w.rangeCount === 0) return false; const range = w.getRangeAt(0); if (range.collapsed === true) { return false; diff --git a/packages/core/src/modules/inline-string.ts b/packages/core/src/modules/inline-string.ts index 99ba47f7..f2836657 100644 --- a/packages/core/src/modules/inline-string.ts +++ b/packages/core/src/modules/inline-string.ts @@ -363,6 +363,7 @@ export function updateInlineStringFormat( // let s = ctx.inlineStringEditCache; const w = window.getSelection(); if (!w) return; + if (w.rangeCount === 0) return; const range = w.getRangeAt(0);