File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
tests/cypress/integration/plugins Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ export default function (Alpine) {
25
25
26
26
let preferences = {
27
27
hideGhost : ! modifiers . includes ( 'ghost' ) ,
28
- useHandles : ! ! el . querySelector ( '[x-sort\\:handle]' ) ,
28
+ useHandles : ( ! ! el . querySelector ( '[x-sort\\:handle]' ) ) || Array . from ( el . querySelectorAll ( 'template' ) ) . some (
29
+ tmpl => ! ! tmpl . content . querySelector ( '[x-sort\\:handle]' )
30
+ ) ,
29
31
group : getGroupName ( el , modifiers ) ,
30
32
}
31
33
Original file line number Diff line number Diff line change @@ -49,13 +49,44 @@ test.skip('can use a custom handle',
49
49
get ( 'ul li' ) . eq ( 0 ) . should ( haveText ( 'handle - foo' ) )
50
50
get ( 'ul li' ) . eq ( 1 ) . should ( haveText ( 'handle - bar' ) )
51
51
52
+ get ( '#1' ) . drag ( '#2' ) . then ( ( ) => {
53
+ get ( 'ul li' ) . eq ( 0 ) . should ( haveText ( 'handle - foo' ) )
54
+ get ( 'ul li' ) . eq ( 1 ) . should ( haveText ( 'handle - bar' ) )
55
+ } )
56
+
52
57
get ( '#1 span' ) . drag ( '#2' ) . then ( ( ) => {
53
58
get ( 'ul li' ) . eq ( 0 ) . should ( haveText ( 'handle - bar' ) )
54
59
get ( 'ul li' ) . eq ( 1 ) . should ( haveText ( 'handle - foo' ) )
55
60
} )
56
61
} ,
57
62
)
58
63
64
+ test ( 'can use a custom handle with x-for' ,
65
+ [ html `
66
+ < div x-data ="{items: ['1', '2']} ">
67
+ < ul x-sort >
68
+ < template x-for ="item in items " :key ="item ">
69
+ < li :id ="item "> < span x-sort:handle > handle</ span > - < span x-text ="item "> </ span > </ li >
70
+ </ template >
71
+ </ ul >
72
+ </ div >
73
+ ` ] ,
74
+ ( { get } ) => {
75
+ get ( 'ul li' ) . eq ( 0 ) . should ( haveText ( 'handle - 1' ) )
76
+ get ( 'ul li' ) . eq ( 1 ) . should ( haveText ( 'handle - 2' ) )
77
+
78
+ get ( '#1' ) . drag ( '#2' ) . then ( ( ) => {
79
+ get ( 'ul li' ) . eq ( 0 ) . should ( haveText ( 'handle - 1' ) )
80
+ get ( 'ul li' ) . eq ( 1 ) . should ( haveText ( 'handle - 2' ) )
81
+ } )
82
+
83
+ get ( '#1 span' ) . eq ( 0 ) . drag ( '#2' ) . then ( ( ) => {
84
+ get ( 'ul li' ) . eq ( 0 ) . should ( haveText ( 'handle - 2' ) )
85
+ get ( 'ul li' ) . eq ( 1 ) . should ( haveText ( 'handle - 1' ) )
86
+ } )
87
+ } ,
88
+ )
89
+
59
90
test . skip ( 'can move items between groups' ,
60
91
[ html `
61
92
< div x-data >
You can’t perform that action at this time.
0 commit comments