@@ -33,6 +33,7 @@ export default class SelectRange extends Module {
3333 this . registerTableOption ( "selectableRangeClearCells" , false ) ; //allow clearing of active range
3434 this . registerTableOption ( "selectableRangeClearCellsValue" , undefined ) ; //value for cleared active range
3535 this . registerTableOption ( "selectableRangeAutoFocus" , true ) ; //focus on a cell after resetRanges
36+ this . registerTableOption ( "selectableRangeBlurEditOnNavigate" , undefined ) ; //prevent editing on navigation
3637
3738 this . registerTableFunction ( "getRangesData" , this . getRangesData . bind ( this ) ) ;
3839 this . registerTableFunction ( "getRanges" , this . getRanges . bind ( this ) ) ;
@@ -66,6 +67,10 @@ export default class SelectRange extends Module {
6667 console . warn ( "Having multiple frozen columns with selectRange option may result in unpredictable behavior." ) ;
6768 }
6869 }
70+
71+ this . subscribe ( "edit-nav-disabled" , ( ) => {
72+ return true ; // Disable navigation in edit module
73+ } ) ;
6974 }
7075
7176
@@ -128,8 +133,8 @@ export default class SelectRange extends Module {
128133 this . subscribe ( "edit-editor-clear" , this . finishEditingCell . bind ( this ) ) ;
129134 this . subscribe ( "edit-blur" , this . restoreFocus . bind ( this ) ) ;
130135
131- this . subscribe ( "keybinding-nav-prev" , this . keyNavigate . bind ( this , "left " ) ) ;
132- this . subscribe ( "keybinding-nav-next" , this . keyNavigate . bind ( this , "right " ) ) ;
136+ this . subscribe ( "keybinding-nav-prev" , this . keyNavigate . bind ( this , "prev " ) ) ;
137+ this . subscribe ( "keybinding-nav-next" , this . keyNavigate . bind ( this , "next " ) ) ;
133138 this . subscribe ( "keybinding-nav-left" , this . keyNavigate . bind ( this , "left" ) ) ;
134139 this . subscribe ( "keybinding-nav-right" , this . keyNavigate . bind ( this , "right" ) ) ;
135140 this . subscribe ( "keybinding-nav-up" , this . keyNavigate . bind ( this , "up" ) ) ;
@@ -142,12 +147,6 @@ export default class SelectRange extends Module {
142147 if ( this . columnSelection && column . definition . headerSort && this . options ( "headerSortClickElement" ) !== "icon" ) {
143148 console . warn ( "Using column headerSort with selectableRangeColumns option may result in unpredictable behavior. Consider using headerSortClickElement: 'icon'." ) ;
144149 }
145-
146- if ( column . modules . edit ) {
147- // Block editor from taking action so we can trigger edit by
148- // double clicking.
149- // column.modules.edit.blocked = true;
150- }
151150 }
152151
153152 updateHeaderColumn ( ) {
@@ -403,6 +402,25 @@ export default class SelectRange extends Module {
403402 ///////////////////////////////////
404403
405404 keyNavigate ( dir , e ) {
405+ if ( this . options ( "selectableRangeBlurEditOnNavigate" ) ) {
406+ const isEditing = this . chain ( "edit-check-editing" ) ;
407+
408+ if ( isEditing ) {
409+ if ( dir === 'next' || dir === 'prev' ) {
410+ this . dispatch ( "edit-cancel-cell" ) ;
411+ } else {
412+ // Prevent navigating while editing except for next/prev
413+ return false ;
414+ }
415+ }
416+ }
417+
418+ if ( dir === 'prev' ) {
419+ dir = 'left' ;
420+ } else if ( dir === 'next' ) {
421+ dir = 'right' ;
422+ }
423+
406424 if ( this . navigate ( false , false , dir ) ) {
407425 e . preventDefault ( ) ;
408426 }
0 commit comments