@@ -2,17 +2,17 @@ import {
22 AfterContentInit , ChangeDetectionStrategy , Component , ContentChild , ContentChildren , ElementRef , Inject , Input , NgZone , OnDestroy , OnInit ,
33 QueryList , Renderer2 , ViewChild
44} from '@angular/core' ;
5- import { BehaviorSubject , iif , merge , NEVER , Observable , Subject , Subscription } from 'rxjs' ;
6- import { exhaustMap , filter , map , startWith , switchMap , take , takeUntil } from 'rxjs/operators' ;
7- import { ktdPointerDown , ktdPointerUp , ktdPointerClient } from '../utils/pointer.utils ' ;
8- import { GRID_ITEM_GET_RENDER_DATA_TOKEN , KtdGridItemRenderDataTokenType } from '../grid.definitions ' ;
5+ import { BehaviorSubject , NEVER , Observable , Subject , Subscription , iif , merge } from 'rxjs' ;
6+ import { exhaustMap , filter , map , startWith , switchMap , take , takeUntil , tap } from 'rxjs/operators' ;
7+ import { BooleanInput , coerceBooleanProperty } from '../coercion/boolean-property ' ;
8+ import { NumberInput , coerceNumberProperty } from '../coercion/number-property ' ;
99import { KTD_GRID_DRAG_HANDLE , KtdGridDragHandle } from '../directives/drag-handle' ;
10+ import { KTD_GRID_ITEM_PLACEHOLDER , KtdGridItemPlaceholder } from '../directives/placeholder' ;
1011import { KTD_GRID_RESIZE_HANDLE , KtdGridResizeHandle } from '../directives/resize-handle' ;
12+ import { GRID_ITEM_GET_RENDER_DATA_TOKEN , KtdGridItemRenderDataTokenType } from '../grid.definitions' ;
1113import { KtdGridService } from '../grid.service' ;
1214import { ktdOutsideZone } from '../utils/operators' ;
13- import { BooleanInput , coerceBooleanProperty } from '../coercion/boolean-property' ;
14- import { coerceNumberProperty , NumberInput } from '../coercion/number-property' ;
15- import { KTD_GRID_ITEM_PLACEHOLDER , KtdGridItemPlaceholder } from '../directives/placeholder' ;
15+ import { ktdIsMouseEventOrMousePointerEvent , ktdPointerClient , ktdPointerDown , ktdPointerUp } from '../utils/pointer.utils' ;
1616
1717@Component ( {
1818 standalone : true ,
@@ -171,9 +171,9 @@ export class KtdGridItemComponent implements OnInit, OnDestroy, AfterContentInit
171171 // with our own dragging (e.g. `img` tags do it by default). Prevent the default action
172172 // to stop it from happening. Note that preventing on `dragstart` also seems to work, but
173173 // it's flaky and it fails if the user drags it away quickly. Also note that we only want
174- // to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
175- // events from firing on touch devices.
176- if ( startEvent . target && ( startEvent . target as HTMLElement ) . draggable && startEvent . type === 'mousedown' ) {
174+ // to do this for `mousedown` and `pointerdown` since doing the same for `touchstart` will
175+ // stop any `click` events from firing on touch devices.
176+ if ( ktdIsMouseEventOrMousePointerEvent ( startEvent ) ) {
177177 startEvent . preventDefault ( ) ;
178178 }
179179
@@ -216,6 +216,11 @@ export class KtdGridItemComponent implements OnInit, OnDestroy, AfterContentInit
216216 this . renderer . setStyle ( this . resizeElem . nativeElement , 'display' , 'block' ) ;
217217 return ktdPointerDown ( this . resizeElem . nativeElement ) ;
218218 }
219+ } ) ,
220+ tap ( ( startEvent ) => {
221+ if ( ktdIsMouseEventOrMousePointerEvent ( startEvent ) ) {
222+ startEvent . preventDefault ( ) ;
223+ }
219224 } )
220225 ) ;
221226 }
0 commit comments