@@ -533,6 +533,22 @@ describe('useShiftRangeSelection', () => {
533533 expect ( nthBatchKeys ( onApplyRange , 1 ) ) . toEqual ( { toSelect : [ 'b' , 'c' ] , toDeselect : [ 'd' ] } ) ;
534534 } ) ;
535535
536+ it ( 'adopts the block when the remembered anchor is gone, since that session is over' , ( ) => {
537+ const onApplyRange = makeApplyMock ( ) ;
538+ const { result, rerender} = renderHook (
539+ ( { items} : { items : Row [ ] } ) => useShiftRangeSelection < Row > ( makeParams ( { items, onApplyRange, isItemSelected : ( row ) => row . keyForList !== 'a' , isItemProtected : ( ) => false } ) ) ,
540+ { initialProps : { items : [ ...ROWS ] } } ,
541+ ) ;
542+ // Anchored on 'a', which the next render drops from the list
543+ act ( ( ) => result . current . notifyAnchor ( ROW_A ) ) ;
544+ rerender ( { items : ROWS . slice ( 1 ) } ) ;
545+ act ( ( ) => {
546+ result . current . applyShiftClick ( ROW_C , true ) ;
547+ } ) ;
548+ // The anchor re-resolved to the block's first row, and the rest of the block fell out of the range with it.
549+ expect ( nthBatchKeys ( onApplyRange , 0 ) ) . toEqual ( { toSelect : [ 'b' , 'c' ] , toDeselect : [ 'd' , 'e' ] } ) ;
550+ } ) ;
551+
536552 it ( 'leaves a block alone when the session already has an anchor, so an unrelated range cannot dissolve it' , ( ) => {
537553 const onApplyRange = makeApplyMock ( ) ;
538554 const { result} = renderHook ( ( ) =>
0 commit comments