@rowsncolumns/spreadsheet 10.5.1 → 10.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAg3LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAm4LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
@@ -120,6 +120,17 @@ var helpers_2 = require("./helpers");
120
120
  */
121
121
  /** Where the grid focuses when no cell is given (A1); mirrors spreadsheet-state's `defaultCellCoords` without importing it — that package depends on this one. */
122
122
  var defaultCellCoords = { rowIndex: 1, columnIndex: 1 };
123
+ /**
124
+ * Whether a registered editor's DOM has been removed: an input that unmounted while focused
125
+ * gets no blur from Chromium, so its `activeEditor` registration can outlive it. Such an editor
126
+ * cannot hold focus, so the grid treats it as absent (rowsncolumns/spreadsheet#1131). An editor
127
+ * that exposes no element is trusted as live.
128
+ */
129
+ function isDetachedEditor(editor) {
130
+ var _a;
131
+ var element = (_a = editor.el) === null || _a === void 0 ? void 0 : _a.call(editor);
132
+ return element != null && !element.isConnected;
133
+ }
123
134
  function CanvasGridComponent(props, forwardedRef) {
124
135
  var _a, _b, _c, _d;
125
136
  var licenseKey = props.licenseKey, sheetId = props.sheetId, sheetType = props.sheetType, _e = props.ChartSheetView, ChartSheetViewComponent = _e === void 0 ? chart_sheet_view_1.ChartSheetView : _e, instanceId = props.instanceId, _f = props.activeCell, activeCell = _f === void 0 ? config_1.DEFAULT_ACTIVE_CELL : _f, _g = props.selections, selections = _g === void 0 ? config_1.DEFAULT_ARRAY : _g, _h = props.frozenColumnCount, frozenColumnCount = _h === void 0 ? 0 : _h, _j = props.frozenRowCount, frozenRowCount = _j === void 0 ? 0 : _j, _k = props.rowCount, rowCount = _k === void 0 ? config_1.DEFAULT_ROW_COUNT : _k, _l = props.columnCount, columnCount = _l === void 0 ? config_1.DEFAULT_COLUMN_COUNT : _l, autoFocus = props.autoFocus, basicFilter = props.basicFilter, tables = props.tables, namedRanges = props.namedRanges, _m = props.bandedRanges, bandedRanges = _m === void 0 ? config_1.DEFAULT_ARRAY : _m, _o = props.tableBorderColor, tableBorderColor = _o === void 0 ? "#008000" : _o, _p = props.filterIconColor, filterIconColor = _p === void 0 ? "#008000" : _p, conditionalFormats = props.conditionalFormats, _q = props.showFilterIcon, showFilterIcon = _q === void 0 ? true : _q, _r = props.showCalculatedColumnIcon, showCalculatedColumnIcon = _r === void 0 ? true : _r, _s = props.showHeaders, showHeaders = _s === void 0 ? true : _s, _t = props.defaultColumnWidth, defaultColumnWidth = _t === void 0 ? config_1.DEFAULT_COLUMN_WIDTH : _t, _u = props.defaultRowHeight, defaultRowHeight = _u === void 0 ? config_1.DEFAULT_ROW_HEIGHT : _u, _v = props.columnHeaderHeight, columnHeaderHeight = _v === void 0 ? config_1.COLUMN_HEADER_HEIGHT : _v, _w = props.rowHeaderWidth, rowHeaderWidth = _w === void 0 ? config_1.ROW_HEADER_WIDTH : _w, _x = props.gridLineColor, gridLineColor = _x === void 0 ? config_1.GRIDLINE_COLOR : _x, _y = props.cellBackgroundColor, cellBackgroundColor = _y === void 0 ? config_1.DEFAULT_CELL_BACKGROUND_COLOR : _y, _z = props.cellColor, cellColor = _z === void 0 ? config_1.DEFAULT_CELL_COLOR : _z, _0 = props.headerBorderColor, headerBorderColor = _0 === void 0 ? config_1.DEFAULT_HEADER_BORDER_COLOR : _0, _1 = props.headerBackgroundColor, headerBackgroundColor = _1 === void 0 ? config_1.DEFAULT_HEADER_BG : _1, _2 = props.headerColor, headerColor = _2 === void 0 ? config_1.DEFAULT_HEADER_COLOR : _2, _3 = props.headerActiveBackgroundColor, headerActiveBackgroundColor = _3 === void 0 ? config_1.DEFAULT_HEADER_ACTIVE_BG : _3, _4 = props.headerSelectedBackgroundColor, headerSelectedBackgroundColor = _4 === void 0 ? config_1.DEFAULT_HEADER_SELECTED_BG : _4, _5 = props.headerSelectedColor, headerSelectedColor = _5 === void 0 ? "white" : _5, _6 = props.headerTableBackgroundColor, headerTableBackgroundColor = _6 === void 0 ? config_1.DEFAULT_HEADER_TABLE_BG : _6, _7 = props.headerTableActiveBackgroundColor, headerTableActiveBackgroundColor = _7 === void 0 ? config_1.DEFAULT_HEADER_ACTIVE_TABLE_BG : _7, _8 = props.headerTableSelectedBackgroundColor, headerTableSelectedBackgroundColor = _8 === void 0 ? config_1.DEFAULT_HEADER_SELECTED_TABLE_BG : _8, _9 = props.frozenShadowColor, frozenShadowColor = _9 === void 0 ? headerBorderColor : _9, _10 = props.frozenShadowThickness, frozenShadowThickness = _10 === void 0 ? 1 : _10, _11 = props.selectionBackgroundColor, selectionBackgroundColor = _11 === void 0 ? config_1.SELECTION_BG : _11, _12 = props.selectionBorderColor, selectionBorderColor = _12 === void 0 ? config_1.SELECTION_BORDER : _12, _13 = props.selectionDragBorderColor, selectionDragBorderColor = _13 === void 0 ? config_1.SELECTION_BORDER : _13, chartSelectedColor = props.chartSelectedColor, _14 = props.chipBackgroundColor, chipBackgroundColor = _14 === void 0 ? config_1.CHIP_COLOR : _14, _15 = props.merges, merges = _15 === void 0 ? config_1.DEFAULT_ARRAY : _15, borderStyles = props.borderStyles, protectedRanges = props.protectedRanges, _16 = props.isWorkbookProtected, isWorkbookProtectedProp = _16 === void 0 ? false : _16, getSheetProtection = props.getSheetProtection, pivotTables = props.pivotTables, charts = props.charts, onUpdateChart = props.onUpdateChart, onChangeZOrder = props.onChangeZOrder, embeds = props.embeds, slicers = props.slicers, _17 = props.rowMetadata, rowMetadata = _17 === void 0 ? config_1.DEFAULT_ARRAY : _17, _18 = props.columnMetadata, columnMetadata = _18 === void 0 ? config_1.DEFAULT_ARRAY : _18, _19 = props.scale, scale = _19 === void 0 ? 1 : _19, _20 = props.zoomSpeed, zoomSpeed = _20 === void 0 ? 1 : _20, _21 = props.overscanCount, overscanCount = _21 === void 0 ? 3 : _21, _22 = props.enableEditOnEnterKey, enableEditOnEnterKey = _22 === void 0 ? true : _22, _23 = props.enableTextOverflow, enableTextOverflow = _23 === void 0 ? true : _23, _showGridLines = props.showGridLines, _24 = props.showFormulas, showFormulas = _24 === void 0 ? false : _24, _25 = props.protectFormulas, protectFormulas = _25 === void 0 ? false : _25, _26 = props.showFrozenSeparator, showFrozenSeparator = _26 === void 0 ? true : _26, _27 = props.HeaderCell, HeaderCell = _27 === void 0 ? header_cell_1.HeaderCell : _27, _28 = props.Cell, Cell = _28 === void 0 ? cell_1.Cell : _28, _29 = props.SelectionTitleComponent, SelectionTitleComponent = _29 === void 0 ? title_1.SelectionTitle : _29, _30 = props.CellEditor, CellEditor = _30 === void 0 ? cell_editor_1.CellEditor : _30, CellTooltip = props.CellTooltip, _31 = props.ContextMenu, ContextMenu = _31 === void 0 ? context_menu_1.ContextMenu : _31, _32 = props.ContextMenuWrapper, ContextMenuWrapper = _32 === void 0 ? use_context_menu_1.DefaultContextMenuWrapper : _32, _33 = props.FilterBox, FilterBox = _33 === void 0 ? filter_box_1.FilterBox : _33, _34 = props.HeaderMoveDragComponent, HeaderMoveDragComponent = _34 === void 0 ? header_move_1.HeaderMoveDragComponent : _34, SuggestionsDropdown = props.SuggestionsDropdown, _35 = props.stickyEditor, stickyEditor = _35 === void 0 ? true : _35, _36 = props.scrollSnap, scrollSnap = _36 === void 0 ? false : _36, scrollThrottleTimeout = props.scrollThrottleTimeout, preventBrowserDefaultScroll = props.preventBrowserDefaultScroll, _37 = props.mouseMoveThrottleTimeout, mouseMoveThrottleTimeout = _37 === void 0 ? 60 : _37, _38 = props.tooltipIntentInterval, tooltipIntentInterval = _38 === void 0 ? 60 : _38, selectionPolicy = props.selectionPolicy, users = props.users, userId = props.userId, renderCollaboratorCursor = props.renderCollaboratorCursor, functionDescriptions = props.functionDescriptions, _39 = props.showHeaderMenuButton, showHeaderMenuButton = _39 === void 0 ? true : _39, _40 = props.scrollbarSize, scrollbarSize = _40 === void 0 ? config_1.SCROLLBAR_SIZE : _40, _41 = props.theme, theme = _41 === void 0 ? config_1.defaultSpreadsheetTheme : _41, _42 = props.showNotes, showNotes = _42 === void 0 ? true : _42, _43 = props.showComments, showComments = _43 === void 0 ? true : _43, locale = props.locale, formulaLocaleProp = props.formulaLocale, agentSuggestions = props.agentSuggestions, onReviewSuggestion = props.onReviewSuggestion, onShowFormulas = props.onShowFormulas, getDataRowCount = props.getDataRowCount, getDataRegion = props.getDataRegion, getChartComponent = props.getChartComponent, getEmbedComponent = props.getEmbedComponent, getSlicerComponent = props.getSlicerComponent, onChange = props.onChange, onChangeBatch = props.onChangeBatch, onExpandCollapse = props.onExpandCollapse, onPivotDrillDown = props.onPivotDrillDown, onDelete = props.onDelete, onChangeEditorValue = props.onChangeEditorValue, onFill = props.onFill, onRequestCalculate = props.onRequestCalculate, onChangeActiveCell = props.onChangeActiveCell, onChangeActiveSheet = props.onChangeActiveSheet, onChangeSelections = props.onChangeSelections, getSheetName = props.getSheetName, getSheetId = props.getSheetId, getCellData = props.getCellData, getNoteProp = props.getNote, getTextFormatRuns = props.getTextFormatRuns, getDataValidation = props.getDataValidation, getEffectiveFormat = props.getEffectiveFormat, getFormattedValueProp = props.getFormattedValue, getTooltipContent = props.getTooltipContent, errorResolutionComponent = props.errorResolutionComponent, getEffectiveValueProp = props.getEffectiveValue, getSparklineGroup = props.getSparklineGroup, getUserEnteredExtendedValue = props.getUserEnteredExtendedValue, getEffectiveExtendedValue = props.getEffectiveExtendedValue, getSheetRowCount = props.getSheetRowCount, getSheetColumnCount = props.getSheetColumnCount, getCellPopoverContent = props.getCellPopoverContent, onScroll = props.onScroll, onViewPortChange = props.onViewPortChange, _44 = props.windowConditionalFormats, windowConditionalFormats = _44 === void 0 ? false : _44, _45 = props.engineConditionalFormatResults, engineConditionalFormatResults = _45 === void 0 ? false : _45, onResize = props.onResize, onAutoResize = props.onAutoResize, onHideColumn = props.onHideColumn, onHideRow = props.onHideRow, onShowColumn = props.onShowColumn, onShowRow = props.onShowRow, onGroupRows = props.onGroupRows, onUngroupRows = props.onUngroupRows, onCollapseRowGroup = props.onCollapseRowGroup, onExpandRowGroup = props.onExpandRowGroup, onGroupColumns = props.onGroupColumns, onUngroupColumns = props.onUngroupColumns, onCollapseColumnGroup = props.onCollapseColumnGroup, onExpandColumnGroup = props.onExpandColumnGroup, onSetOutlineDepth = props.onSetOutlineDepth, onDeleteRow = props.onDeleteRow, onDeleteColumn = props.onDeleteColumn, onInsertRow = props.onInsertRow, onInsertColumn = props.onInsertColumn, onChangeAutoExpandTables = props.onChangeAutoExpandTables, onChangeAutoCalculatedColumns = props.onChangeAutoCalculatedColumns, onInsertCellsShiftDown = props.onInsertCellsShiftDown, onInsertCellsShiftRight = props.onInsertCellsShiftRight, onDeleteCellsShiftLeft = props.onDeleteCellsShiftLeft, onDeleteCellsShiftUp = props.onDeleteCellsShiftUp, onClearContents = props.onClearContents, onMoveColumns = props.onMoveColumns, onMoveRows = props.onMoveRows, onSelectNextSheet = props.onSelectNextSheet, onSelectPreviousSheet = props.onSelectPreviousSheet, onCreateNewSheet = props.onCreateNewSheet, onKeyDown = props.onKeyDown, onChangeFormatting = props.onChangeFormatting, onRepeatFormatting = props.onRepeatFormatting, onClearFormatting = props.onClearFormatting, onRequestEditProtectedRange = props.onRequestEditProtectedRange, onMoveChart = props.onMoveChart, onResizeChart = props.onResizeChart, onDeleteChart = props.onDeleteChart, onCutChart = props.onCutChart, onCopyChart = props.onCopyChart, onMoveEmbed = props.onMoveEmbed, onResizeEmbed = props.onResizeEmbed, onDeleteEmbed = props.onDeleteEmbed, onRequestEditEmbed = props.onRequestEditEmbed, onMoveSlicer = props.onMoveSlicer, onResizeSlicer = props.onResizeSlicer, onDeleteSlicer = props.onDeleteSlicer, onRequestEditSlicer = props.onRequestEditSlicer, onFillRange = props.onFillRange, disableFillRightShortcut = props.disableFillRightShortcut, keymap = props.keymap, onCalculateNow = props.onCalculateNow, onRequestGoTo = props.onRequestGoTo, onMoveSelection = props.onMoveSelection, onInsertCutCells = props.onInsertCutCells, onInsertTime = props.onInsertTime, onInsertDate = props.onInsertDate, onInsertDateTime = props.onInsertDateTime, onInsertAutoSum = props.onInsertAutoSum, onUndo = props.onUndo, onRedo = props.onRedo, onPaste = props.onPaste, onCopy = props.onCopy, onCut = props.onCut, onSortColumn = props.onSortColumn, onSortTable = props.onSortTable, onFilterTable = props.onFilterTable, onFilterPivot = props.onFilterPivot, onResizeTable = props.onResizeTable, onUndoTableAutoExpansion = props.onUndoTableAutoExpansion, onUndoCalculatedColumn = props.onUndoCalculatedColumn, onOverwriteCalculatedColumn = props.onOverwriteCalculatedColumn, onRequestEditTable = props.onRequestEditTable, onRequestEditPivotTable = props.onRequestEditPivotTable, onRequestDeletePivotTable = props.onRequestDeletePivotTable, onRequestCreatePivotChart = props.onRequestCreatePivotChart, onRemoveTable = props.onRemoveTable, onCreateTable = props.onCreateTable, onRequestCreateTable = props.onRequestCreateTable, onInsertTableColumn = props.onInsertTableColumn, onDeleteTableColumn = props.onDeleteTableColumn, onInsertTableRow = props.onInsertTableRow, onDeleteTableRow = props.onDeleteTableRow, onUpdateTable = props.onUpdateTable, onRequestResizeTable = props.onRequestResizeTable, onRequestInsertSlicer = props.onRequestInsertSlicer, onCreateBasicFilter = props.onCreateBasicFilter, onRequestDefineNamedRange = props.onRequestDefineNamedRange, onRequestFormatCells = props.onRequestFormatCells, onRequestConditionalFormat = props.onRequestConditionalFormat, onRequestDataValidation = props.onRequestDataValidation, onRequestInsertComment = props.onRequestInsertComment, onRequestInsertLink = props.onRequestInsertLink, onFreezeColumn = props.onFreezeColumn, onFreezeRow = props.onFreezeRow, onUpdateNote = props.onUpdateNote, onProtectRange = props.onProtectRange, onUnProtectRange = props.onUnProtectRange, onSortRange = props.onSortRange, onRequestSearch = props.onRequestSearch, onRequestReplace = props.onRequestReplace, onRequestResize = props.onRequestResize, _46 = props.getRowHeaderText, getRowHeaderText = _46 === void 0 ? helpers_1.getDefaultRowHeader : _46, _47 = props.getColumnHeaderText, getColumnHeaderText = _47 === void 0 ? helpers_1.getDefaultColumnHeader : _47, getAdditionalCellSpacing = props.getAdditionalCellSpacing, _48 = props.tokenizer, defaultTokenizer = _48 === void 0 ? calculator_1.tokenize : _48, onChangeScale = props.onChangeScale, onRemoveLink = props.onRemoveLink, onSelectLink = props.onSelectLink, onSplitTextToColumns = props.onSplitTextToColumns, onRemoveDuplicates = props.onRemoveDuplicates, onGoalSeek = props.onGoalSeek, onSubtotal = props.onSubtotal, onAdvancedFilter = props.onAdvancedFilter, onRequestExpand = props.onRequestExpand, cellExpandPredicate = props.cellExpandPredicate, _49 = props.StructuredResult, StructuredResult = _49 === void 0 ? cell_structured_1.StructuredResultRenderer : _49, getMentions = props.getMentions, getStructuredPropertiesProp = props.getStructuredProperties, getFunctionParameterSuggestions = props.getFunctionParameterSuggestions, shouldFetchFunctionParameters = props.shouldFetchFunctionParameters, MentionTagComponent = props.MentionTagComponent, MentionDropdownItemComponent = props.MentionDropdownItemComponent, _50 = props.showSelectionResizeHandles, showSelectionResizeHandles = _50 === void 0 ? true : _50, enableMagicFill = props.enableMagicFill, _51 = props.enableQuickEdit, enableQuickEdit = _51 === void 0 ? true : _51, MagicFillComponent = props.MagicFillComponent, MagicFillContent = props.MagicFillContent, QuickEdit = props.QuickEdit, PasteMenu = props.PasteMenu, SuggestionAction = props.SuggestionAction, HiddenRowMarkers = props.HiddenRowMarkers, HiddenColumnMarkers = props.HiddenColumnMarkers, enableResizerOverflow = props.enableResizerOverflow, className = props.className, _52 = props.defaultFontSizePoint, defaultFontSizePoint = _52 === void 0 ? config_1.DEFAULT_FONT_SIZE_PT : _52, defaultCellFormat = props.defaultCellFormat, readonly = props.readonly, _53 = props.isComparing, isComparing = _53 === void 0 ? false : _53, getCellDiff = props.getCellDiff, enableDataBoundaryNavigation = props.enableDataBoundaryNavigation, footerHeight = props.footerHeight, footerComponent = props.footerComponent, arrowComponents = props.arrowComponents,
@@ -817,7 +828,13 @@ function CanvasGridComponent(props, forwardedRef) {
817
828
  !gridContainer.contains(activeElement)) {
818
829
  return;
819
830
  }
820
- if (!activeEditor || activeEditor === cellEditorInstance) {
831
+ // An editor whose DOM is gone cannot be the one holding focus: a host that unmounted an
832
+ // input without a blur (Chromium fires none for a removed focused element) can leave a
833
+ // stale `activeEditor` behind, and honouring it would lock the grid out of keyboard input
834
+ // (rowsncolumns/spreadsheet#1131).
835
+ if (!activeEditor ||
836
+ activeEditor === cellEditorInstance ||
837
+ isDetachedEditor(activeEditor)) {
821
838
  cellEditorInstance === null || cellEditorInstance === void 0 ? void 0 : cellEditorInstance.focus();
822
839
  }
823
840
  }, [activeEditor, cellEditorInstance]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAiB,MAAM,OAAO,CAAC;AActC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,sGA8JxB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAiB,MAAM,OAAO,CAAC;AActC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,sGAuLxB,CAAC"}
@@ -33,6 +33,9 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
33
33
  // to be the one to turn it off; otherwise the picked range keeps rendering and the
34
34
  // grid stays in formula-selection mode with no editor left to receive the picks.
35
35
  var ownsFormulaModeRef = (0, react_2.useRef)(false);
36
+ // Whether this input holds focus (set on focus, cleared on blur): an input that unmounts
37
+ // while focused got no blur, and is the editor `activeEditor` still points at.
38
+ var focusedRef = (0, react_2.useRef)(false);
36
39
  var enterFormulaMode = (0, react_1.useCallback)(function (nextValue) {
37
40
  var formulaMode = (0, utils_1.isAFormula)(nextValue);
38
41
  setFormulaMode(formulaMode);
@@ -46,13 +49,35 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
46
49
  }, [onCancel, setFormulaMode, setFormulaSelections]);
47
50
  // Layout (not passive) cleanup: when a host re-keys its range inputs ("Add range"),
48
51
  // the departing input must release the mode before the new one's autoFocus claims it.
52
+ // The same cleanup releases `activeEditor` when it still points at this input: Chromium
53
+ // fires no blur for a focused element that is removed (a dialog closed with Escape while
54
+ // the input had focus), so `handleBlur` never ran, and CanvasGrid skips focusing its own
55
+ // cell editor for as long as another editor is registered — the grid stops taking
56
+ // keyboard input until something else clears it (rowsncolumns/spreadsheet#1131).
49
57
  (0, use_isomorphic_layout_effect_1.useIsomorphicLayoutEffect)(function () { return function () {
58
+ var _a, _b;
50
59
  if (ownsFormulaModeRef.current) {
51
60
  ownsFormulaModeRef.current = false;
52
61
  setFormulaMode(false);
53
62
  setFormulaSelections([]);
54
63
  }
55
- }; }, [setFormulaMode, setFormulaSelections]);
64
+ // The registration is CellInput's live handle, which can be a newer object than the one
65
+ // forwarded here at mount, so match on the element too; and an input removed while it
66
+ // still had focus (`focusedRef`) is the registered one even if neither identity matches.
67
+ var editor = editorRef.current;
68
+ var element = (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.el) === null || _a === void 0 ? void 0 : _a.call(editor)) !== null && _b !== void 0 ? _b : null;
69
+ var wasFocused = focusedRef.current;
70
+ focusedRef.current = false;
71
+ setActiveEditor(function (current) {
72
+ var _a;
73
+ if (current === undefined)
74
+ return current;
75
+ var ours = current === editor ||
76
+ (element !== null && ((_a = current.el) === null || _a === void 0 ? void 0 : _a.call(current)) === element) ||
77
+ wasFocused;
78
+ return ours ? undefined : current;
79
+ });
80
+ }; }, [setActiveEditor, setFormulaMode, setFormulaSelections]);
56
81
  var handleFocus = (0, react_1.useCallback)(function (e) {
57
82
  var _a;
58
83
  // Set formula mode
@@ -64,6 +89,7 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
64
89
  }
65
90
  // Move to end of input
66
91
  (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.moveCursorToEnd();
92
+ focusedRef.current = true;
67
93
  // Trigger change
68
94
  onChange === null || onChange === void 0 ? void 0 : onChange(value);
69
95
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
@@ -82,6 +108,7 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
82
108
  return;
83
109
  }
84
110
  closeFormulaMode();
111
+ focusedRef.current = false;
85
112
  // Resetting active editor will
86
113
  // cause the dropdown to close if open
87
114
  setActiveEditor(undefined);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAg3LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAoDA,OAAO,KASN,MAAM,OAAO,CAAC;AAqNf,OAAO,KAAK,EAGV,QAAQ,EAWT,MAAM,aAAa,CAAC;AAoBrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAm4LnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
@@ -116,6 +116,16 @@ import { getNestedPropertyNames } from "./helpers";
116
116
  */
117
117
  /** Where the grid focuses when no cell is given (A1); mirrors spreadsheet-state's `defaultCellCoords` without importing it — that package depends on this one. */
118
118
  const defaultCellCoords = { rowIndex: 1, columnIndex: 1 };
119
+ /**
120
+ * Whether a registered editor's DOM has been removed: an input that unmounted while focused
121
+ * gets no blur from Chromium, so its `activeEditor` registration can outlive it. Such an editor
122
+ * cannot hold focus, so the grid treats it as absent (rowsncolumns/spreadsheet#1131). An editor
123
+ * that exposes no element is trusted as live.
124
+ */
125
+ function isDetachedEditor(editor) {
126
+ const element = editor.el?.();
127
+ return element != null && !element.isConnected;
128
+ }
119
129
  function CanvasGridComponent(props, forwardedRef) {
120
130
  const { licenseKey, sheetId, sheetType, ChartSheetView: ChartSheetViewComponent = ChartSheetView, instanceId, activeCell = DEFAULT_ACTIVE_CELL, selections = DEFAULT_ARRAY, frozenColumnCount = 0, frozenRowCount = 0, rowCount = DEFAULT_ROW_COUNT, columnCount = DEFAULT_COLUMN_COUNT, autoFocus, basicFilter, tables, namedRanges, bandedRanges = DEFAULT_ARRAY, tableBorderColor = "#008000", filterIconColor = "#008000", conditionalFormats, showFilterIcon = true, showCalculatedColumnIcon = true, showHeaders = true, defaultColumnWidth = DEFAULT_COLUMN_WIDTH, defaultRowHeight = DEFAULT_ROW_HEIGHT, columnHeaderHeight = COLUMN_HEADER_HEIGHT, rowHeaderWidth = ROW_HEADER_WIDTH, gridLineColor = GRIDLINE_COLOR, cellBackgroundColor = DEFAULT_CELL_BACKGROUND_COLOR, cellColor = DEFAULT_CELL_COLOR, headerBorderColor = DEFAULT_HEADER_BORDER_COLOR, headerBackgroundColor = DEFAULT_HEADER_BG, headerColor = DEFAULT_HEADER_COLOR, headerActiveBackgroundColor = DEFAULT_HEADER_ACTIVE_BG, headerSelectedBackgroundColor = DEFAULT_HEADER_SELECTED_BG, headerSelectedColor = "white", headerTableBackgroundColor = DEFAULT_HEADER_TABLE_BG, headerTableActiveBackgroundColor = DEFAULT_HEADER_ACTIVE_TABLE_BG, headerTableSelectedBackgroundColor = DEFAULT_HEADER_SELECTED_TABLE_BG, frozenShadowColor = headerBorderColor, frozenShadowThickness = 1, selectionBackgroundColor = SELECTION_BG, selectionBorderColor = SELECTION_BORDER, selectionDragBorderColor = SELECTION_BORDER, chartSelectedColor, chipBackgroundColor = CHIP_COLOR, merges = DEFAULT_ARRAY, borderStyles, protectedRanges, isWorkbookProtected: isWorkbookProtectedProp = false, getSheetProtection, pivotTables, charts, onUpdateChart, onChangeZOrder, embeds, slicers, rowMetadata = DEFAULT_ARRAY, columnMetadata = DEFAULT_ARRAY, scale = 1, zoomSpeed = 1, overscanCount = 3, enableEditOnEnterKey = true, enableTextOverflow = true, showGridLines: _showGridLines, showFormulas = false, protectFormulas = false, showFrozenSeparator = true, HeaderCell = DefaultHeaderCell, Cell = DefaultCell, SelectionTitleComponent = SelectionTitle, CellEditor = DefaultCellEditor, CellTooltip, ContextMenu = DefaultContextMenu, ContextMenuWrapper = DefaultContextMenuWrapper, FilterBox = DefaultFilterBox, HeaderMoveDragComponent = DefaultHeaderMoveDragComponent, SuggestionsDropdown, stickyEditor = true, scrollSnap = false, scrollThrottleTimeout, preventBrowserDefaultScroll, mouseMoveThrottleTimeout = 60, tooltipIntentInterval = 60, selectionPolicy, users, userId, renderCollaboratorCursor, functionDescriptions, showHeaderMenuButton = true, scrollbarSize = SCROLLBAR_SIZE, theme = defaultSpreadsheetTheme, showNotes = true, showComments = true, locale, formulaLocale: formulaLocaleProp, agentSuggestions, onReviewSuggestion, onShowFormulas, getDataRowCount, getDataRegion, getChartComponent, getEmbedComponent, getSlicerComponent, onChange, onChangeBatch, onExpandCollapse, onPivotDrillDown, onDelete, onChangeEditorValue, onFill, onRequestCalculate, onChangeActiveCell, onChangeActiveSheet, onChangeSelections, getSheetName, getSheetId, getCellData, getNote: getNoteProp, getTextFormatRuns, getDataValidation, getEffectiveFormat, getFormattedValue: getFormattedValueProp, getTooltipContent, errorResolutionComponent, getEffectiveValue: getEffectiveValueProp, getSparklineGroup, getUserEnteredExtendedValue, getEffectiveExtendedValue, getSheetRowCount, getSheetColumnCount, getCellPopoverContent, onScroll, onViewPortChange, windowConditionalFormats = false, engineConditionalFormatResults = false, onResize, onAutoResize, onHideColumn, onHideRow, onShowColumn, onShowRow, onGroupRows, onUngroupRows, onCollapseRowGroup, onExpandRowGroup, onGroupColumns, onUngroupColumns, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, onDeleteRow, onDeleteColumn, onInsertRow, onInsertColumn, onChangeAutoExpandTables, onChangeAutoCalculatedColumns, onInsertCellsShiftDown, onInsertCellsShiftRight, onDeleteCellsShiftLeft, onDeleteCellsShiftUp, onClearContents, onMoveColumns, onMoveRows, onSelectNextSheet, onSelectPreviousSheet, onCreateNewSheet, onKeyDown, onChangeFormatting, onRepeatFormatting, onClearFormatting, onRequestEditProtectedRange, onMoveChart, onResizeChart, onDeleteChart, onCutChart, onCopyChart, onMoveEmbed, onResizeEmbed, onDeleteEmbed, onRequestEditEmbed, onMoveSlicer, onResizeSlicer, onDeleteSlicer, onRequestEditSlicer, onFillRange, disableFillRightShortcut, keymap, onCalculateNow, onRequestGoTo, onMoveSelection, onInsertCutCells, onInsertTime, onInsertDate, onInsertDateTime, onInsertAutoSum, onUndo, onRedo, onPaste, onCopy, onCut, onSortColumn, onSortTable, onFilterTable, onFilterPivot, onResizeTable, onUndoTableAutoExpansion, onUndoCalculatedColumn, onOverwriteCalculatedColumn, onRequestEditTable, onRequestEditPivotTable, onRequestDeletePivotTable, onRequestCreatePivotChart, onRemoveTable, onCreateTable, onRequestCreateTable, onInsertTableColumn, onDeleteTableColumn, onInsertTableRow, onDeleteTableRow, onUpdateTable, onRequestResizeTable, onRequestInsertSlicer, onCreateBasicFilter, onRequestDefineNamedRange, onRequestFormatCells, onRequestConditionalFormat, onRequestDataValidation, onRequestInsertComment, onRequestInsertLink, onFreezeColumn, onFreezeRow, onUpdateNote, onProtectRange, onUnProtectRange, onSortRange, onRequestSearch, onRequestReplace, onRequestResize, getRowHeaderText = getDefaultRowHeader, getColumnHeaderText = getDefaultColumnHeader, getAdditionalCellSpacing, tokenizer: defaultTokenizer = defaultFormulaTokenizer, onChangeScale, onRemoveLink, onSelectLink, onSplitTextToColumns, onRemoveDuplicates, onGoalSeek, onSubtotal, onAdvancedFilter, onRequestExpand, cellExpandPredicate, StructuredResult = DefaultStructuredResult, getMentions, getStructuredProperties: getStructuredPropertiesProp, getFunctionParameterSuggestions, shouldFetchFunctionParameters, MentionTagComponent, MentionDropdownItemComponent, showSelectionResizeHandles = true, enableMagicFill, enableQuickEdit = true, MagicFillComponent, MagicFillContent, QuickEdit, PasteMenu, SuggestionAction, HiddenRowMarkers, HiddenColumnMarkers, enableResizerOverflow, className, defaultFontSizePoint = DEFAULT_FONT_SIZE_PT, defaultCellFormat, readonly, isComparing = false, getCellDiff, enableDataBoundaryNavigation, footerHeight, footerComponent, arrowComponents,
121
131
  // Host-driven filter props. `hostHiddenRowRanges`
@@ -696,7 +706,13 @@ function CanvasGridComponent(props, forwardedRef) {
696
706
  !gridContainer.contains(activeElement)) {
697
707
  return;
698
708
  }
699
- if (!activeEditor || activeEditor === cellEditorInstance) {
709
+ // An editor whose DOM is gone cannot be the one holding focus: a host that unmounted an
710
+ // input without a blur (Chromium fires none for a removed focused element) can leave a
711
+ // stale `activeEditor` behind, and honouring it would lock the grid out of keyboard input
712
+ // (rowsncolumns/spreadsheet#1131).
713
+ if (!activeEditor ||
714
+ activeEditor === cellEditorInstance ||
715
+ isDetachedEditor(activeEditor)) {
700
716
  cellEditorInstance?.focus();
701
717
  }
702
718
  }, [activeEditor, cellEditorInstance]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAiB,MAAM,OAAO,CAAC;AActC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,sGA8JxB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAiB,MAAM,OAAO,CAAC;AActC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,sGAuLxB,CAAC"}
@@ -28,6 +28,9 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
28
28
  // to be the one to turn it off; otherwise the picked range keeps rendering and the
29
29
  // grid stays in formula-selection mode with no editor left to receive the picks.
30
30
  const ownsFormulaModeRef = useRef(false);
31
+ // Whether this input holds focus (set on focus, cleared on blur): an input that unmounts
32
+ // while focused got no blur, and is the editor `activeEditor` still points at.
33
+ const focusedRef = useRef(false);
31
34
  const enterFormulaMode = useCallback((nextValue) => {
32
35
  const formulaMode = isAFormula(nextValue);
33
36
  setFormulaMode(formulaMode);
@@ -41,13 +44,33 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
41
44
  }, [onCancel, setFormulaMode, setFormulaSelections]);
42
45
  // Layout (not passive) cleanup: when a host re-keys its range inputs ("Add range"),
43
46
  // the departing input must release the mode before the new one's autoFocus claims it.
47
+ // The same cleanup releases `activeEditor` when it still points at this input: Chromium
48
+ // fires no blur for a focused element that is removed (a dialog closed with Escape while
49
+ // the input had focus), so `handleBlur` never ran, and CanvasGrid skips focusing its own
50
+ // cell editor for as long as another editor is registered — the grid stops taking
51
+ // keyboard input until something else clears it (rowsncolumns/spreadsheet#1131).
44
52
  useIsomorphicLayoutEffect(() => () => {
45
53
  if (ownsFormulaModeRef.current) {
46
54
  ownsFormulaModeRef.current = false;
47
55
  setFormulaMode(false);
48
56
  setFormulaSelections([]);
49
57
  }
50
- }, [setFormulaMode, setFormulaSelections]);
58
+ // The registration is CellInput's live handle, which can be a newer object than the one
59
+ // forwarded here at mount, so match on the element too; and an input removed while it
60
+ // still had focus (`focusedRef`) is the registered one even if neither identity matches.
61
+ const editor = editorRef.current;
62
+ const element = editor?.el?.() ?? null;
63
+ const wasFocused = focusedRef.current;
64
+ focusedRef.current = false;
65
+ setActiveEditor((current) => {
66
+ if (current === undefined)
67
+ return current;
68
+ const ours = current === editor ||
69
+ (element !== null && current.el?.() === element) ||
70
+ wasFocused;
71
+ return ours ? undefined : current;
72
+ });
73
+ }, [setActiveEditor, setFormulaMode, setFormulaSelections]);
51
74
  const handleFocus = useCallback((e) => {
52
75
  // Set formula mode
53
76
  enterFormulaMode(value);
@@ -58,6 +81,7 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
58
81
  }
59
82
  // Move to end of input
60
83
  editorRef.current?.moveCursorToEnd();
84
+ focusedRef.current = true;
61
85
  // Trigger change
62
86
  onChange?.(value);
63
87
  onFocus?.(e);
@@ -75,6 +99,7 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
75
99
  return;
76
100
  }
77
101
  closeFormulaMode();
102
+ focusedRef.current = false;
78
103
  // Resetting active editor will
79
104
  // cause the dropdown to close if open
80
105
  setActiveEditor(undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/spreadsheet",
3
- "version": "10.5.1",
3
+ "version": "10.5.2",
4
4
  "author": "Vinay M",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./dist/cjs/index.js",