@@ -24,7 +24,7 @@ import {CUSTOM_DRAG_TYPE} from '@react-aria/dnd/src/constants';
2424import { DataTransfer , DataTransferItem , DragEvent , FileSystemDirectoryEntry , FileSystemFileEntry } from '@react-aria/dnd/test/mocks' ;
2525import { DIRECTORY_DRAG_TYPE } from '@react-aria/dnd' ;
2626import { DragBetweenTablesComplex } from '../stories/TableDnDUtilExamples' ;
27- import { DragBetweenTablesExample , DragBetweenTablesRootOnlyExample , DragExample , DragOntoRowExample , ReorderExample } from '../stories/TableDnDExamples' ;
27+ import { DragBetweenTablesExample , DragBetweenTablesRootOnlyExample , DragExample , DragOntoRowExample , DragWithoutRowHeaderExample , ReorderExample } from '../stories/TableDnDExamples' ;
2828import { Droppable } from '@react-aria/dnd/test/examples' ;
2929import { Flex } from '@react-spectrum/layout' ;
3030import { globalDndState } from '@react-aria/dnd/src/utils' ;
@@ -114,6 +114,12 @@ describe('TableView', function () {
114114 ) ;
115115 }
116116
117+ function DraggbleWithoutRowHeader ( props ) {
118+ return (
119+ < DragWithoutRowHeaderExample onDrop = { onDrop } onDragStart = { onDragStart } onDragEnd = { onDragEnd } { ...props } />
120+ ) ;
121+ }
122+
117123 function Reorderable ( props ) {
118124 return (
119125 < ReorderExample disabledKeys = { [ 'a' ] } onDrop = { onDrop } onDragStart = { onDragStart } onDragEnd = { onDragEnd } { ...props } />
@@ -197,6 +203,56 @@ describe('TableView', function () {
197203 expect ( dataTransfer . _dragImage . y ) . toBe ( 5 ) ;
198204 } ) ;
199205
206+ it ( 'should render a drag preview with highlight selection style' , function ( ) {
207+ let { getByRole, getAllByText} = render (
208+ < DraggbleWithoutRowHeader tableViewProps = { { selectedKeys : [ 'a' ] , selectionStyle : 'highlight' } } />
209+ ) ;
210+
211+ let grid = getByRole ( 'grid' ) ;
212+ let rowgroups = within ( grid ) . getAllByRole ( 'rowgroup' ) ;
213+ let rows = within ( rowgroups [ 1 ] ) . getAllByRole ( 'row' ) ;
214+ let row = rows [ 0 ] ;
215+ let cell = within ( row ) . getAllByRole ( 'rowheader' ) [ 0 ] ;
216+ let cellText = getAllByText ( cell . textContent ) ;
217+ expect ( cellText ) . toHaveLength ( 1 ) ;
218+
219+ let dataTransfer = new DataTransfer ( ) ;
220+
221+ fireEvent . pointerDown ( cell , { pointerType : 'mouse' , button : 0 , pointerId : 1 , clientX : 5 , clientY : 5 } ) ;
222+ fireEvent ( cell , new DragEvent ( 'dragstart' , { dataTransfer, clientX : 5 , clientY : 5 } ) ) ;
223+ expect ( dataTransfer . _dragImage . node . tagName ) . toBe ( 'DIV' ) ;
224+
225+ // Verify that when no rowHeader is set, the drag preview displays the text of the first element of the row
226+ expect ( dataTransfer . _dragImage . node . textContent ) . toBe ( 'Vin' ) ;
227+ expect ( dataTransfer . _dragImage . x ) . toBe ( 5 ) ;
228+ expect ( dataTransfer . _dragImage . y ) . toBe ( 5 ) ;
229+ } ) ;
230+
231+ it ( 'should render a drag preview with checkbox selection style' , function ( ) {
232+ let { getByRole, getAllByText} = render (
233+ < DraggbleWithoutRowHeader tableViewProps = { { selectedKeys : [ 'a' ] , selectionStyle : 'checkbox' } } />
234+ ) ;
235+
236+ let grid = getByRole ( 'grid' ) ;
237+ let rowgroups = within ( grid ) . getAllByRole ( 'rowgroup' ) ;
238+ let rows = within ( rowgroups [ 1 ] ) . getAllByRole ( 'row' ) ;
239+ let row = rows [ 0 ] ;
240+ let cell = within ( row ) . getAllByRole ( 'rowheader' ) [ 0 ] ;
241+ let cellText = getAllByText ( cell . textContent ) ;
242+ expect ( cellText ) . toHaveLength ( 1 ) ;
243+
244+ let dataTransfer = new DataTransfer ( ) ;
245+
246+ fireEvent . pointerDown ( cell , { pointerType : 'mouse' , button : 0 , pointerId : 1 , clientX : 5 , clientY : 5 } ) ;
247+ fireEvent ( cell , new DragEvent ( 'dragstart' , { dataTransfer, clientX : 5 , clientY : 5 } ) ) ;
248+
249+ // Verify that when no rowHeader is set, the drag preview displays the text of the first element of the row
250+ expect ( dataTransfer . _dragImage . node . tagName ) . toBe ( 'DIV' ) ;
251+ expect ( dataTransfer . _dragImage . node . textContent ) . toBe ( 'Vin' ) ;
252+ expect ( dataTransfer . _dragImage . x ) . toBe ( 5 ) ;
253+ expect ( dataTransfer . _dragImage . y ) . toBe ( 5 ) ;
254+ } ) ;
255+
200256
201257 it ( 'should allow drag and drop of a single row' , async function ( ) {
202258 let { getByRole, getByText} = render (
0 commit comments