@@ -4,7 +4,9 @@ import { aTimeout, fixtureSync, listenOnce, nextFrame, nextResize } from '@vaadi
44import sinon from 'sinon' ;
55import './grid-test-styles.js' ;
66import '../src/vaadin-grid.js' ;
7+ import { isChrome } from '@vaadin/component-base/src/browser-utils.js' ;
78import {
9+ cellDraggableAttribute ,
810 dragAndDropOver ,
911 flushGrid ,
1012 getBodyCellContent ,
@@ -25,7 +27,7 @@ describe('drag and drop', () => {
2527 const getDraggable = ( grid , rowIndex = 0 ) => {
2628 const row = Array . from ( grid . $ . items . children ) . find ( ( row ) => row . index === rowIndex ) ;
2729 const cellContent = row . querySelector ( 'slot' ) . assignedNodes ( ) [ 0 ] ;
28- return [ row , cellContent ] . find ( ( node ) => node . getAttribute ( 'draggable' ) === 'true' ) ;
30+ return [ row , cellContent ] . find ( ( node ) => node . getAttribute ( cellDraggableAttribute ) === 'true' ) ;
2931 } ;
3032
3133 const fireDragStart = ( draggable = getDraggable ( grid ) ) => {
@@ -154,6 +156,39 @@ describe('drag and drop', () => {
154156 expect ( getDraggable ( grid ) ) . not . to . be . ok ;
155157 } ) ;
156158
159+ // See https://github.com/vaadin/web-components/issues/11726
160+ describe ( 'accessible name workaround' , ( ) => {
161+ const getContent = ( row = 0 ) => getBodyCellContent ( grid , row , 0 ) ;
162+
163+ ( isChrome ? it : it . skip ) ( 'should not set the draggable attribute on Chromium' , ( ) => {
164+ expect ( getContent ( ) . hasAttribute ( 'draggable' ) ) . to . be . false ;
165+ } ) ;
166+
167+ ( isChrome ? it : it . skip ) ( 'should mark draggable content with draggable-source styles on Chromium' , ( ) => {
168+ expect ( getContent ( ) . getAttribute ( 'draggable-source' ) ) . to . equal ( 'true' ) ;
169+ const style = getComputedStyle ( getContent ( ) ) ;
170+ expect ( style . webkitUserDrag ) . to . equal ( 'element' ) ;
171+ expect ( style . userSelect ) . to . equal ( 'none' ) ;
172+ } ) ;
173+
174+ ( isChrome ? it . skip : it ) ( 'should set the draggable attribute on other browsers' , ( ) => {
175+ expect ( getContent ( ) . getAttribute ( 'draggable' ) ) . to . equal ( 'true' ) ;
176+ } ) ;
177+
178+ it ( 'should unset the drag marker when rowsDraggable is disabled' , ( ) => {
179+ grid . rowsDraggable = false ;
180+ flushGrid ( grid ) ;
181+ expect ( getContent ( ) . hasAttribute ( cellDraggableAttribute ) ) . to . be . false ;
182+ } ) ;
183+
184+ it ( 'should not set the drag marker on rows excluded by dragFilter' , ( ) => {
185+ grid . dragFilter = ( model ) => model . index !== 0 ;
186+ flushGrid ( grid ) ;
187+ expect ( getContent ( 0 ) . hasAttribute ( cellDraggableAttribute ) ) . to . be . false ;
188+ expect ( getContent ( 1 ) . getAttribute ( cellDraggableAttribute ) ) . to . equal ( 'true' ) ;
189+ } ) ;
190+ } ) ;
191+
157192 describe ( 'dragstart' , ( ) => {
158193 let dragStartSpy ;
159194 let dropSpy ;
0 commit comments