@@ -442,8 +442,6 @@ describe('Splitter', () => {
442442 expect ( currentSizes . endSize ) . to . equal ( previousSizes . endSize ) ;
443443 checkResizeEvents ( eventSpy ) ;
444444 } ) ;
445- // TODO: test when the slots have assigned sizes/min sizes + edge cases
446- // currently observing issue when resizing to the end and panes have fixed px sizes
447445
448446 it ( 'should resize horizontally by 10px delta with left/right arrow keys' , async ( ) => {
449447 const eventSpy = spy ( splitter , 'emitEvent' ) ;
@@ -789,6 +787,74 @@ describe('Splitter', () => {
789787 expect ( splitter . endCollapsed ) . to . be . false ;
790788 } ) ;
791789 } ) ;
790+
791+ // TODO: test when the slots have assigned sizes/min sizes + edge cases
792+ describe ( 'Resizing with constraints and edge cases' , ( ) => {
793+ it ( 'panes should not exceed splitter size when set in px and horizontally resizing to end' , async ( ) => {
794+ splitter = await fixture < IgcSplitterComponent > (
795+ createTwoPanesWithSizesAndConstraints ( {
796+ startSize : '500px' ,
797+ endSize : '500px' ,
798+ } )
799+ ) ;
800+ const totalSplitterSize = 800 ;
801+ splitter . style . width = `${ totalSplitterSize } px` ;
802+ await elementUpdated ( splitter ) ;
803+
804+ const bar = getSplitterPart ( splitter , 'bar' ) ;
805+ const barSize = bar . getBoundingClientRect ( ) . width ;
806+ const previousSizes = getPanesSizes ( splitter , 'width' ) ;
807+ const deltaX = 100 ;
808+
809+ await resize ( splitter , deltaX , 0 ) ;
810+
811+ const currentSizes = getPanesSizes ( splitter , 'width' ) ;
812+ expect ( currentSizes . startSize ) . to . equal ( previousSizes . startSize + deltaX ) ;
813+ // end pane size should be decreased to fit the splitter width
814+ expect ( currentSizes . endSize ) . to . equal (
815+ totalSplitterSize - barSize - currentSizes . startSize
816+ ) ;
817+ checkPanesAreWithingBounds (
818+ splitter ,
819+ currentSizes . startSize ,
820+ currentSizes . endSize ,
821+ 'x'
822+ ) ;
823+ } ) ;
824+
825+ it ( 'panes should not exceed splitter size when set in px and vertically resizing to end' , async ( ) => {
826+ splitter = await fixture < IgcSplitterComponent > (
827+ createTwoPanesWithSizesAndConstraints ( {
828+ orientation : 'vertical' ,
829+ startSize : '500px' ,
830+ endSize : '500px' ,
831+ } )
832+ ) ;
833+ const totalSplitterSize = 800 ;
834+ splitter . style . height = `${ totalSplitterSize } px` ;
835+ await elementUpdated ( splitter ) ;
836+
837+ const bar = getSplitterPart ( splitter , 'bar' ) ;
838+ const barSize = bar . getBoundingClientRect ( ) . height ;
839+ const previousSizes = getPanesSizes ( splitter , 'height' ) ;
840+ const deltaY = 100 ;
841+
842+ await resize ( splitter , 0 , deltaY ) ;
843+
844+ const currentSizes = getPanesSizes ( splitter , 'height' ) ;
845+ expect ( currentSizes . startSize ) . to . equal ( previousSizes . startSize + deltaY ) ;
846+ // end pane size should be decreased to fit the splitter height
847+ expect ( currentSizes . endSize ) . to . equal (
848+ totalSplitterSize - barSize - currentSizes . startSize
849+ ) ;
850+ checkPanesAreWithingBounds (
851+ splitter ,
852+ currentSizes . startSize ,
853+ currentSizes . endSize ,
854+ 'y'
855+ ) ;
856+ } ) ;
857+ } ) ;
792858} ) ;
793859
794860function createSplitter ( ) {
@@ -831,12 +897,12 @@ function createTwoPanesWithSizesAndConstraints(
831897 return html `
832898 < igc-splitter
833899 .orientation =${ config . orientation ?? 'horizontal' }
834- .startSize =${ config . startSize ?? 'auto' }
835- .endSize=${ config . endSize ?? 'auto' }
836- .startMinSize=${ config . startMinSize ?? '0px' }
837- .startMaxSize=${ config . startMaxSize ?? '100%' }
838- .endMinSize=${ config . endMinSize ?? '0px' }
839- .endMaxSize=${ config . endMaxSize ?? '100%' }
900+ .startSize =${ config . startSize }
901+ .endSize=${ config . endSize }
902+ .startMinSize=${ config . startMinSize }
903+ .startMaxSize=${ config . startMaxSize }
904+ .endMinSize=${ config . endMinSize }
905+ .endMaxSize=${ config . endMaxSize }
840906 >
841907 < div slot ="start "> Pane 1</ div >
842908 < div slot ="end "> Pane 2</ div >
@@ -918,13 +984,13 @@ function checkResizeEvents(eventSpy: sinon.SinonSpy) {
918984 eventSpy . resetHistory ( ) ;
919985}
920986
921- // function checkPanesAreWithingBounds(
922- // splitter: IgcSplitterComponent,
923- // startSize: number,
924- // endSize: number,
925- // dimension: 'x' | 'y'
926- // ) {
927- // const splitterSize =
928- // splitter.getBoundingClientRect()[dimension === 'x' ? 'width' : 'height'];
929- // expect(startSize + endSize).to.be.at.most(splitterSize);
930- // }
987+ function checkPanesAreWithingBounds (
988+ splitter : IgcSplitterComponent ,
989+ startSize : number ,
990+ endSize : number ,
991+ dimension : 'x' | 'y'
992+ ) {
993+ const splitterSize =
994+ splitter . getBoundingClientRect ( ) [ dimension === 'x' ? 'width' : 'height' ] ;
995+ expect ( startSize + endSize ) . to . be . at . most ( splitterSize ) ;
996+ }
0 commit comments