File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed
src/components/tile-manager Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -226,5 +226,34 @@ describe('Tile resize', () => {
226226 expect ( eventSpy ) . calledWith ( 'igcResize' ) ;
227227 expect ( tile . getAttribute ( 'part' ) ) . to . include ( 'resizing' ) ;
228228 } ) ;
229+
230+ it ( 'tile should not span more columns than the column count' , async ( ) => {
231+ const tile = first ( getTiles ( ) ) ;
232+ const tileDOM = getTileDOM ( tile ) ;
233+ const eventSpy = spy ( tileDOM . resizeElement , 'emitEvent' ) ;
234+
235+ tileManager . columnCount = 3 ;
236+
237+ simulatePointerDown ( tileDOM . resizeTrigger ) ;
238+ await elementUpdated ( tileDOM . resizeElement ) ;
239+
240+ expect ( eventSpy ) . calledWith ( 'igcResizeStart' ) ;
241+
242+ simulatePointerMove ( tileDOM . resizeTrigger , {
243+ clientX : 3000 ,
244+ } ) ;
245+ await elementUpdated ( tileDOM . resizeElement ) ;
246+
247+ expect ( eventSpy ) . calledWith ( 'igcResize' ) ;
248+
249+ simulateLostPointerCapture ( tileDOM . resizeTrigger ) ;
250+ await elementUpdated ( tileDOM . resizeElement ) ;
251+
252+ expect ( eventSpy ) . calledWith ( 'igcResizeEnd' ) ;
253+
254+ expect (
255+ Number . parseFloat ( getComputedStyle ( tile ) . gridColumn . split ( ' ' ) [ 1 ] )
256+ ) . to . equal ( tileManager . columnCount ) ;
257+ } ) ;
229258 } ) ;
230259} ) ;
Original file line number Diff line number Diff line change @@ -542,10 +542,21 @@ export default class IgcTileComponent extends EventEmitterMixin<
542542
543543 private _handleResizeEnd ( event : CustomEvent < ResizeCallbackParams > ) {
544544 const state = event . detail . state ;
545- const width = state . current . width ;
546545 const height = state . current . height ;
546+ let width = state . current . width ;
547547
548- const colSpan = Math . max ( 1 , Math . round ( width / this . gridColumnWidth ) ) ;
548+ if ( width > this . parentElement ! . getBoundingClientRect ( ) . width ) {
549+ width =
550+ this . parentElement ! . getBoundingClientRect ( ) . width - state . current . x ;
551+ }
552+
553+ let colSpan = Math . max (
554+ 1 ,
555+ Math . round ( width / ( this . gridColumnWidth + this . _cachedStyles . gap ! ) )
556+ ) ;
557+ colSpan = this . _cachedStyles . columnCount
558+ ? Math . min ( colSpan , this . _cachedStyles . columnCount ! )
559+ : colSpan ;
549560
550561 const initialTop = event . detail . state . initial . top + window . scrollY ;
551562 const startRowIndex = ResizeUtil . calculate (
You can’t perform that action at this time.
0 commit comments