@@ -7,6 +7,7 @@ import ContextMenu from '@js/ui/context_menu';
77import modules from '../m_modules' ;
88
99const CONTEXT_MENU = 'dx-context-menu' ;
10+ const GROUP_ROW_CLASS = 'dx-group-row' ;
1011
1112const viewName = {
1213 columnHeadersView : 'header' ,
@@ -28,20 +29,26 @@ export class ContextMenuController extends modules.ViewController {
2829
2930 const that = this ;
3031 const $targetElement = $ ( dxEvent . target ) ;
31- let $element ;
32- let $targetRowElement ;
33- let $targetCellElement ;
3432 let menuItems ;
3533
3634 each ( VIEW_NAMES , function ( ) {
3735 const view = that . getView ( this ) ;
38- $element = view && view . element ( ) ;
3936
40- if ( $element && ( $element . is ( $targetElement ) || $element . find ( $targetElement ) . length ) ) {
41- $targetCellElement = $targetElement . closest ( '.dx-row > td, .dx-row > tr' ) ;
42- $targetRowElement = $targetCellElement . parent ( ) ;
37+ if ( ! view ) {
38+ return ;
39+ }
40+
41+ const $viewElement = view . element ( ) ;
42+ const isTargetElementInsideView = $viewElement ?. is ( $targetElement ) || $viewElement ?. find ( $targetElement ) . length ;
43+
44+ if ( isTargetElementInsideView ) {
45+ const isGroupRow = $targetElement . hasClass ( GROUP_ROW_CLASS ) ;
46+ const $targetCellElement = isGroupRow
47+ ? $targetElement . find ( '.dx-group-cell' ) . first ( )
48+ : $targetElement . closest ( '.dx-row > td, .dx-row > tr' ) ;
49+ const $targetRowElement = $targetCellElement . parent ( ) ;
4350 const rowIndex = view . getRowIndex ( $targetRowElement ) ;
44- const columnIndex = $targetCellElement [ 0 ] && $targetCellElement [ 0 ] . cellIndex ;
51+ const columnIndex = $targetCellElement [ 0 ] ? .cellIndex ;
4552 const rowOptions = $targetRowElement . data ( 'options' ) ;
4653 const options : any = {
4754 event : dxEvent ,
@@ -50,6 +57,7 @@ export class ContextMenuController extends modules.ViewController {
5057 rowIndex,
5158 row : view . _getRows ( ) [ rowIndex ] ,
5259 columnIndex,
60+ // @ts -expect-error
5361 column : rowOptions ?. cells ?. [ columnIndex ] ?. column ,
5462 } ;
5563
0 commit comments